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.
No comments:
Post a Comment