locked
Debugging Visual Studio 2010/SharePoint 2010 application RRS feed

  • Question

  • I was able to debug Visual Studio 2010/SharePoint 2010 application. But then I perform a few IIS reset and a few times attached and detached w3wp processes. Now I cannot debug the VS 2010 application and the program never hits the breakpoint. It appears some settings hae been affected. Any solution or ideas?

    Sunday, November 20, 2011 11:56 PM

Answers

All replies

  • Hey,

    Restart the VS2010 and again open the sharepoint application in VS2010 and attach all w3wp.exe and then again debug the code.

    I think it will hit the breakpoint this time.

    Give a try :)


    "The Only Way To Get Smarter Is By Playing A Smarter Opponent"
    Monday, November 21, 2011 4:21 AM
  • Try this way

    1. Rebuild your solution and put your assembly / dll in GAC.

    2. Recycle your application pool in IIS.

    3. Refresh the browser / your site.

    4. Attach debugger to all w3wp worker processes.

    Everytime you do changes in your code , the latest assembly needs to be placed in GAC if you need debugging to work fine.

    also

    If you are using SharePoint 2010 then are you deploying the solution as Farm Solution or as Sandbox solution?

    If you are deploying as a Farm solution then steps mentioned above should work , you can verify your assembly / .dll in the [OSDrive:\Windows\Assembly] folder. This location is called as GAC - Global Assembly Cache

    If you are deploying as a Sandbox solution then , you need to attach the debugger to the SPUCWorkerProcess.exe (Reference : http://msdn.microsoft.com/en-us/magazine/ee335711.aspx)

    Hope this helps you.



    Bhushan | http://www.passionatetechie.blogspot.com | http://twitter.com/BhushanGawale
    Monday, November 21, 2011 4:51 AM
  • Hi Bhushan,

    I tried but it does not work. Nothing seems to work. Looks like something has changed the original settings. I am using the Farm solution. Any other clue.

     

    Mayank

     

    Monday, November 21, 2011 6:01 AM
  • Can you try adding this line to your code, then redeploy, iisreset and try to run that piece of code:

    System.Diagnostics.Debugger.Break();

    When your code hits that line, it should ask you whether to attach to the process or not.

    Kind regards,
    Jeroen


    Blog: Skavi
    Monday, November 21, 2011 8:23 AM
  • Hi,

    You may try this -

    1) Uninstall the dll in the GAC

    2) Run an iisreset

    3) Reinstall the dll in GAC ( deploy the solution )

    4) Run an iisreset

    Thanks,

     


    Priyanka
    Monday, November 21, 2011 8:53 AM
  • Thanks Jeroen. But where do I add

    System.Diagnostics.Debugger.Break();

    Also, what do I need to reference.

    Monday, November 21, 2011 6:02 PM
  • Thanks Priyanka. Your solution worked for some applications but not for others. Do I need to do something else. How about attaching to w3wp processes. When to attach them. Thanks a lot.
    Monday, November 21, 2011 8:34 PM
  • Hi,

    Hope the below steps help  :

    1) Uninstall the dll in the GAC
    2) Run an iisreset
    3)Re-install the dll in the GAC
    4) Run an iisreset
    5) Refresh the browser / your site.
    6) Attach debugger to w3wp worker processes ( mostly you should see only one w3wp process).

    OR

    1)      From VS 2010 Retract the solution

    2)      Run an iisreset

    3)      From VS 2010 Deploy the solution and Run an iisreset

    4)      Refresh the browser / your site.

    5)      Attach debugger to w3wp worker processes ( mostly you should see only one w3wp process).

    You can also debug using System.Diagnostics.Debugger.Launch(); statement. To do so, you can place this line of code from where you intend to start debugging. Once you have included this statement in your code you can compile the dll and include it in GAC or deploy the solution

    The main idea behind doing these steps is to ensure that you have LATEST dlls for the respective solutions. I have faced this many time after subsequent debug attempts J

    Thanks & Regards,


    Priyanka
    Tuesday, November 22, 2011 6:59 AM
  • Hello Priyanka,

    thanks again. I am not able to insert System.Diagnostics.Debugger.Launch(); . What is the namespace? I already have System.Diagnostics.

    Nothing seems to work. I am not sure what is going wrong. The debugger works in some applications but not in others. Wonder why. Any other ideas

    Wednesday, November 23, 2011 12:55 AM
  • Hi,

    Make sure you have attached all w3wp.exe processes for debugger.

    To get the appropriate w3wp.exe, please use the following command:

    cd \d "c:\windows\system32\inetsrv"
    appcmd list wp

    http://www.codeproject.com/Articles/190933/Tip-Debugging-a-SharePoint-2010-Timed-Job?msg=3886127

    And before you click the attach button. Check the "Attach to" field, then only select the Managed V2.0 1.1 1.0 option to see if it make sense.

    Also check the dll of the "other applications" in GAC. if possible, retracting these entire solution. Then rebuild, repackage, clear the browser cache, redeploy.

    You can also check this link:

    http://www.ronaldwidha.net/2010/10/10/cant-step-intodebug-sharepoint-2010-referenced-projects-or-assemblies/

    BTW, are you debugging on the same server as sharepoint? Remote debugging is not supported.

    Typically, hit F5 in visual studio, it will attaching, set up debugging and deploying automatically for you.

    Hope this can help.


    • Edited by Zizhuoye Chen Tuesday, November 29, 2011 8:15 AM
    • Marked as answer by Qiao Wei Monday, December 5, 2011 3:12 AM
    Tuesday, November 29, 2011 8:10 AM