Debuging WSS 3/MOSS 2007

15 01 2009

In all these years on developping, I have found that one of the main productivity factors is the ability to find the cause of the errors. Once you know where they are happening, solving is usually faster. This knowledge is an ongoing process that you build upon, and the longer you work on a certain tecnology/platform/programming language the faster you will be able to work your way arount it. In order to help you to achieve this state, I have put together some topics that are really just common knowledge, but that would have saved me some hard time when I have started to develop on Sharepoint. The debugging tips that I normally use are:

  1. Turn off Custom Errors: This tag basically controls what error pages your web site will show when an error occurs.  In most cases you would not want to show a full stack trace to the world when an error occurs so I would opt for setting this to On for most of the time and RemoteOnly when you want to debug something.  If it is a dev only system though knock yourself out and set it to Off.  You can set this tag in the <system.web> tag though it should already exist for you to modify.  More info on the tag here.
    • On: This will always show a simple error has occured page and will not show details.
    • RemoteOnly: This will show a simple error has occured page to remote clients and a full stack trace to a browser from the local server.
    • Off: This shows a full stack trace to everyone when an error occurs.
    • Ex: <customErrors mode=”RemoteOnly” />   

  2. Enable stack trace: in your web.config file enable the CallStack and AllowPageLevelTrace parameters
        <SafeMode MaxControls=”200″ CallStack=”true” DirectFileDependencies=”10″ TotalFileDependencies=”50″ AllowPageLevelTrace=”true”>   

  3. Add an HttpModule to handle exceptions of type “An unknow error has occured.”: Here is a post whith that approach.  
  4. Attach the debugger to the process W3WP (be sure to attach to the right one as there may be more than one. When in doubt, attach to all of them. Don’t forget to copy the *.pdb to the location of your dll (GAC or Bin). Some tools (i.e. WSPBuilder) have shortcuts to help you in this process.  Use the command iisapp.vbs to check which application pool is running he site you want to debug.
  5. Attach the debugger to the process owstimer: if you need to debug workflows, for example, you will need to attach the debugger to this process.  
  6. Use windbg: when the going gets tough, go right to the bone. Some links on windbg:

How about you? Any other hints? Looking forward to hear from you!

Have fun!

Offtopic: Mind broadening presentations

14 01 2009

I have recently been shown by a colleague, to a huge presentation application that publish TED contents to everyone. TED is a cross segment forum with ~20 min presentations on topics that go from robotics to how to survive to an atom bomb. This is a chance to listen to excellent presentation skills on some very interesting topics. Check it out at