16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1016 Part IX: Maintaining a Server in Windows SharePoint Services<br />

If you want to start the debugging process manually <strong>and</strong> you already have<br />

code-behind assemblies <strong>and</strong> a symbol table in place, you do not have to change any<br />

settings within Visual Studio .NET. In this scenario, you will not be able to debug<br />

inline code.<br />

If you want to debug code within the .aspx page itself <strong>and</strong> you want ASP.NET<br />

to generate the symbol table, for any pages that it compiles you need to set the trust<br />

level in the Web.config file to at least WSS_Medium.<br />

If you want Visual Studio .NET to automatically attach itself to the process that<br />

runs your Web Part, you need to set the debugging settings to true. You can do this by<br />

setting the debug attribute of the element in the Web.config file to<br />

True, like this: . You should also make sure<br />

that debugging is enabled for your Web Part library project. You can do this by rightclicking<br />

the project name in the Solution Explorer <strong>and</strong> choosing Properties. Then<br />

choose Configuration Properties | \Debugging, <strong>and</strong> set Enable ASP.NET Debugging<br />

to True.<br />

The next step in the debugging process, regardless of the scenario that applies to<br />

you, is to set breakpoints in your code. For example, the RenderWebPart method<br />

would be a good place to set a breakpoint. You can set breakpoints by opening your<br />

Web Part assembly in Visual Studio.NET, going to the line of code where you want to<br />

enter a breakpoint, right-clicking the line, <strong>and</strong> then clicking Insert Breakpoint.<br />

To manually attach to the process<br />

You can manually attach to the W3wp.exe process to debug your Web Part. This<br />

method is less useful in situations where you are in the middle of a repeated development<br />

<strong>and</strong> debugging cycle. On the other h<strong>and</strong>, this method is extremely helpful<br />

in situations where you are attempting to debug code access security–related problems.<br />

In a scenario in which you are automatically attaching to a process, you might<br />

have to artificially raise the trust level (to at least WSS_Medium). This could possibly<br />

hide security exceptions that might be encountered only at lower trust levels.<br />

1. Set up a Web Part Page with the Web Part you want to debug on your local<br />

SharePoint server.<br />

2. Attach the debugger to the ASP.NET process: W3wp.exe.<br />

a. On the Debug menu, click Processes.<br />

b. Select the Show system processes <strong>and</strong> Show processes in all sessions<br />

check boxes.<br />

c. In the Available Processes list, select W3wp.exe <strong>and</strong> then click Attach.<br />

d. In the Attach to Process dialog box, select Common Language Runtime<br />

<strong>and</strong> then click OK.<br />

e. Click Close.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!