1. Debugging with Visual Studio extensions for Windows SharePoint Services
Press the F5 key to begin debugging with Visual Studio extensions for Windows SharePoint Services. The following procedure demonstrates how to enable F5 debugging.
To enable F5 debugging
Locate and open the target SharePoint application's Web.config file. By default, it is located in C:\Inetpub\wwwroot\wss\VirtualDirectories\80.
Find the following line of code and change the debug attribute to true.
Save the changes to the Web.config file.
In Visual Studio, right-click the SharePoint project, and then click Properties.
Click the Debug tab, and then type the target SharePoint URL in the Start browser with URL box.
Place a breakpoint in the code, and then press F5.
2. Performing Manual Debugging
You can debug a SharePoint application without using Visual Studio extensions for Windows SharePoint Services by attaching it to the W3wp.exe process. The following procedure demonstrates how to do this.
To attach to the W3wp.exe process
Make sure that the SharePoint application is using the latest compiled source code. This may require that you recompile your source and install the assemblies into the global assembly cache. Alternatively, you may need to copy the assemblies to the bin folder of SharePoint's virtual directory. In either case, you must run the Microsoft Internet Information Services (IIS) command-line utility Iisreset.exe.
Place a breakpoint in the code you want to debug.
On the Debug menu, 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 and Show processes in all sessions check boxes are selected.
If the W3wp.exe process still is not listed, open a Web browser and navigate to the application's SharePoint site. After you navigate to the SharePoint site, return to Visual Studio. In the Attach to Process dialog box, click the Refresh button to locate the W3wp.exe process.
If you see multiple W3wp.exe processes listed and are not sure which one of them is running the code, click them all.
Click the Attach button.
3. Performing Remote Debugging
You can debug a SharePoint application when it is running on a remote computer by attaching it to the remote W3wp.exe process. The following procedure demonstrates how to do this.
To attach to a remote W3wp.exe process
Make sure that the remote SharePoint application is using the latest compiled source code. This may mean that you must recompile your source and install the assemblies into the global assembly cache of the remote server. Alternatively, you may need to copy the assemblies to the bin folder of SharePoint's virtual directory on the remote computer. In either case, you must run the Microsoft Internet Information Services (IIS) command-line utility Iisreset.exe.
Make sure that the Visual Studio 2008 Remote Debugger is installed on the remote computer.
Start the Visual Studio 2008 Remote Debugger on the remote computer. For more information about using the remote debugger, see How to: Run the Remote Debugging Monitor on MSDN.
In Visual Studio on the local computer, open the solution, and then set a breakpoint.
On the Debug menu, click Attach to Process.
In the Qualifier text box, type the name of the remote computer, and then click Refresh.
In the Available Processes list, 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 and Show processes in all sessions check boxes are selected.
If the W3wp.exe process still is not listed, open a Web browser and navigate to the application's SharePoint site. After you navigate to the SharePoint site, return to Visual Studio. In the Attach to Process dialog box, click the Refresh button to locate the W3wp.exe process.
If you see multiple W3wp.exe processes listed and are not sure which one of them is running the code, click them all. Click Attach.
No comments:
Post a Comment