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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 37: Using Visual Studio .NET to Create Web Parts 1017<br />

You are now ready to step through your code.<br />

To use a start-up page <strong>and</strong> automatically attach to the process<br />

You can automatically attach to the W3wp.exe process for debugging purposes. This<br />

method is probably the one you will use most often during Web Part development.<br />

1. Right-click the project name in the Solution Explorer, <strong>and</strong> then click Properties.<br />

2. Click Configuration Properties, <strong>and</strong> then click Debugging.<br />

3. Under Start Action, set Debug Mode to URL <strong>and</strong> then set Start URL to the<br />

URL of the Web Part Page that uses your Web Part.<br />

4. Click OK, <strong>and</strong> then save your project.<br />

5. On the Debug menu, click Start. The debugger should launch the browser<br />

with your Web Part Page, attach to the process, <strong>and</strong> allow you to debug automatically.<br />

After attaching to the W3wp.exe process, you are now ready to step through the<br />

code. Request the Web Part Page with the target Web Part in it. As the Web Part Page<br />

<strong>and</strong> the Web Part render, depending on where the breakpoint is set you will notice that<br />

the control switches to the Visual Studio debugger. Once the control is in the debugger,<br />

you can step through the code <strong>and</strong> identify the problem by using the debugger’s<br />

available functionality.<br />

Using the CallStack Attribute<br />

Windows SharePoint Services overrides the CallStack attribute. This attribute is<br />

located in the Web.config file. The CallStack attribute controls whether a call stack<br />

<strong>and</strong> an exception message are displayed when a system-level exception occurs<br />

while ASP.NET processes a request to send a page to all local <strong>and</strong> remote clients. By<br />

default, Windows SharePoint Services disables the CallStack attribute <strong>and</strong> displays a<br />

limited set of exceptions to prevent information disclosure.<br />

To enable the CallStack attribute<br />

To receive a call stack <strong>and</strong> an exception message when an exception occurs, enable<br />

the CallStack attribute.<br />

1. In Windows Explorer, browse to the root folder of the Windows SharePoint Services<br />

extended virtual server, for example: local_drive:\InetPub\wwwroot\bin\.<br />

2. Double-click the Web.config file.<br />

3. In the Web.config file, search for the element.<br />

4. In the element, locate the tag <strong>and</strong> change it to .<br />

5. Save <strong>and</strong> close the file.

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

Saved successfully!

Ooh no, something went wrong!