Sunday, May 25, 2008

Use DebugView in Windows SharePoint Services 3.0 and MOSS programming

While programming Windows SharePoint Services or MOSS Sites, tools, debugView allows you to display trace messages at runtime.
How to use it ?
Download dbgview.exe. Simply execute the DebugView program file (dbgview.exe) and DebugView will immediately start capturing debug output.

Warning:
You have to set to true the "debug" attribute in "configuration" section of the concerned Web Application.



You must select "Capture Win32" and "Capture Events" in Capture Menu



To expose your code traces to DebugView, use this kind of instruction :

System.Diagnostics.Debug.WriteLine("myVar1Value : " + Var1.Value);


Why to use it ?
  • After having deployed. You can check traces on a server where there is no Visual Studio set up.
  • You can debug your in line code while using NotePad.
  • You can debug without using Visual Studio console, or spoiling your pages with "Response.Write" instructions.
  • It is very comfortable to have your traces written in an other window than Visual Studio. You have more space to write traces and check them.
  • After having developed your application, you don't need to clear the debug instructions from your code. You compile in Realease mode, and all instructions are ignored, excepted if you check that checkbox in Visual Studio (right click your project in Solution Explorer Window, and select "Properties"):

    Define DEBUG Constant

Go to the TechNet reference page.
You will find the link to download DebugView at the bottom of the page.

No comments: