Allow Debugging for SharePoint - Part 1
Written By: Hesham Saad -- 4/19/2011 --
(4) comments --
Categories: MOSS 2007, System Administration, Visual Studio, WSS3
At some point SharePoint developers will need to trace, log and debug
their code when they get tripped up with bugs or any weird things when
building custom solutions, applications, or components for
SharePoint hides the real detailed error messages and debug /tracing
information which relate to the error. In order to display it we
can debug SharePoint Applications & Solutions using the detailed
steps below :
- Enable debug information and tracing over bugs
and exceptions on WSS (Windows SharePoint Services) 3.0 & MOSS
(Microsoft Office SharePoint Server) 2007 - Part 1.
- Enable debug information and tracing over bugs and exceptions on
SharePoint 2010 - Part 2.
1. Enable debug information and tracing over bugs and
exceptions on WSS (Windows SharePoint Services) 3.0 & MOSS (Microsoft
Office SharePoint Server) 2007:
We can allow debugging/tracing in SharePoint 2007 by using the multiple approaches below:
I. "Debugging with VSEWSS (Visual Studio Extensions For Windows SharePoint Services)": [F5 Debugging]
- Locate and open the target
SharePoint applications "Web.Config" file . (Usually located at:
- Search and find the below line of
code and change "debug" attribute to "true" then save the change:
- Search and find the
below line of code and change "CallStack" attribute to "true" then save
- Search and find the
below line of code and change "mode" attribute to "Off" then save the
- Then in Visual Studio, Right
click the SharePoint Project and then click properties.
- Click the "Debug" tab then type
the target SharePoint URL in the 'start browser with URL' box.
Then, place a breakpoint either
by clicking on the line of code or pressing F9 on the selected line of code and then
II. "Manual Debugging": [w3wp.exe
Attach to Process]
We can debug SharePoint
applications without using VSEWSS [F5 Debugging] by attaching to the
w3wp.exe process by using the following procedures:
- The SharePoint application must
use the latest compiled source code. We need to recompile the source
code and install the assemblies into the GAC (Global Assembly Cache -
usually located at: C:\Windows\assembly). Alternatively, we may need to copy the
assemblies to the bin folder of the SharePoint virtual directory. This
application>\bin". In either case we must run the Microsoft Internet
Information Services (IIS) command-line utility "iisreset.exe"
by opening a command prompt and typing "iisreset".
breakpoint in the code that we want to debug.
Click on the "Debug"
menu then click "Attach to Process".
In the list of
available processes, find the W3wp.exe process and then do the
following, as applicable:
If the W3wp.exe process is not listed make sure that the "Show
processes from all users" & "Show processes in all sessions" check boxes
If the W3wp.exe process is still not listed, open a web browser and
navigate to the application SharePoint site. Then return to the Visual Studio, then
"Attach to process" and click the refresh button to locate the W3wp.exe
If you see multiple W3wp.exe process listed and ae not sure which one is
running the code, we can click them all or open a "cmd" window and type "iisapp"
towhich W3wp.exe process number is mapped to our web application port number.
Click the Attach button.
III. "Remote Debugging":
[W3wp.exe Remote Attach to Process]
We can debug a SharePoint application which is running
on a remote computer by attaching to the remote W3wp.exe process by using the following procedures:
Repeat step (1)
at "Manual Debugging".
Make sure that
Visual Studio remote debugger is installed on the remote computer
and then start the
Then open Visual Studio on the local computer
and open the solution. Then set
Click on the
Debug menu. Then click on "Attach to process". Then in the Qualifier text
box, type the name of the remote computer and then click Refresh.
Then in the
Available Processes list , find the W3wp.exe process then repeat step
(4) at "Manual Debugging".