|
I've been reading a lot of posts on how to get debugging going when attaching to the w3wp.exe process. Disable 'Enable Just My Code' in Visual StudioThis blog post Modify the web.configFurthermore, it prompted me to change the web.config value from debug="false" to debug="true". The web.config file can be found in the Inetpub\wwwroot\wss\VirtualDirectories\ folder, each folder in there maps to an IIS Web Application which you can find by going to IIS Manager and looking at the Home Directory. Setting CallStack=trueBy default, WSS will redirect a user to the error page whenever an unhandled exception is encountered during the render cycle. To disable this behavior, open your web.config and set CallStack="true" in the <SafeMode> node. This allows you to see a typical Asp.net error page. Setting customErrors mode...The next step would be set mode="Off" in the <customErrors> node. This instructs Asp.net to show you a complete error report rather than a generic "Server Error" page. Creating pdbsFor each project you wish to debug, you need to ensure that you are creating pdbs. I am using the really cool stsdev app to create my projects and had to modify it to create pdbs by going to Project Properties and on the Build tab in the Output Section click the Advanced button.
Attach to ProcessThe author of the previous referenced post also pointed me to running iisapp on the command line to output a list of all the running instance to know which process to attach to: Sometimes there are just too many instances of w3wp.exe to pick from. An easy way to just let the system sort things out for you, rather than inserting a breakpoint, is to insert the following line in your code: System.Diagnostics.Debugger.Break();
Notes for Visual Studio Debugging NewbiesOnce you are actually debugging and can step through code after it breaks on a breakpoint...you can also use the Immediate window to inspect objects by pressing CTRL-ALT-I. From here you can get up intellisense on any object in context which is a great way to inspect things like whether a SharePoint list has an Event Receiver on it or not.
The web server process that was being debugged has been terminated by Internet Information Services (IIS)If you are debugging in IIS7.0 you will find that you will receive this error if you leave it on a break point for too long.
Unknown macro: {NewCode}
--------------------------- The Resolution is to follow these steps on MSDN - Error: Web site worker process has been terminated by IIS Tools for DebuggingAttach to Process within SharePoint site
DebugViewDebug View is a great tool for development that when left running on the server can display any debug messages written to Debug.WriteLine. SPTraceViewSPTraceView is a great way to monitor the trace logs in real time. You can see Exceptions popup from your taskbar. |
SharePoint Development Debugging

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. Hosted generously by CustomWare












Comments (2)
Mar 23, 2009
Alex Angas says:
Any info on how to debug JavaScript and CSS would be helpful. One pain point is ...Any info on how to debug JavaScript and CSS would be helpful. One pain point is when these files get cached and you discover you are debugging an out of date version.
Thanks!
Sep 16, 2009
Anonymous says:
You can use third part plugin for ie or firefox; for instance on ie8 there is th...You can use third part plugin for ie or firefox; for instance on ie8 there is the developer tools intgrated and from where you can debug the javascript