Home > development, error, event handlers, MOSS, MS SharePoint Sever, sharepoint, sps > Correctly Debugging with Visual Studio 2008

Correctly Debugging with Visual Studio 2008

When your project is ready for debugging, make sure you do not change ANYTHING in your code after you have built the project. Follow the steps IN ORDER:

  • Place a breakpoint in your code
  • Rebuild your project
  • Drop the dll into the GAC
  • Do an IISRESET
  • Refresh the web/sharepoint page (F5)
  • Attach with w3wp.exe process. (In visual studio, go to “Debug –> Attach to Process –> w3wp.exe –> Attach”)

This will put your project in debugging mode. Remember to do these steps in order. Some of your breakpoints may not be active generating a message “Symbols not loaded”. That’s because you may be working with an event handler and it is not fired as yet (so no worries). As soon as the event handler fires, the symbols will be acitvated automatically. For instance, if it is an ItemAdded event handler, go add a document to the document library and the breakpoints will be hit as they are executed.

If the breakpoints are not hit, that means your code is not executed, that can happen if you didnt perform the actions that will execute the code marked with breakpoints, e.g. in case of an ItemAdded event handler you didnt add any item to the document library.

It could also be the case that you made changes to your code, if so, repeat the above process in order.

When the breakpoints are hit, press F5 to move forward from one breakpoint to another in order of execution (Visual Studio 2008).

When your code is attached to a process do NOT hit the stop button, this will terminate the running process and terminate the SharePoint Web application.

Always click “Debug –> Detach All”. In this way Visual Studio will leave the process without taking the sharepoint application down with it.

Hope this helps–

  1. June 8, 2010 at 8:26 pm

    THANK YOU, been jacking with this all day!
    quick and easy answer.

  1. January 4, 2010 at 9:27 am
  2. January 7, 2010 at 6:24 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: