RaSor's Tech Blog

October 24, 2008

WSS Dev: HowTo debug a WebPart

Filed under: Sharepoint — rasor @ 4:52 pm

Can you debug a webpart in a WSS page? Yes – not a problem.

Prerequisites:

  • From WSPBuilder make your Webpart (WP). See here.
  • Activate the feature containing the WP
  • Add the WP to a site page
  • Open the page in a browser

Debug:

  • In VisualStudio (VS) set a breakpoint in your WP code
  • RightClick (RC) project – Build (Shift+F6)
  • RC project – WSP – Copy2Gac
  • (RC project – WSP – Recycle) => w3wp.exe will be shutdown and a new one will be created when a request to a page is done.
  • RC project – WSP – Attach – choose w3wp.exe (the one with sql…?) => The breakpoint will be unfilled and not yet be reachable
  • Refresh the browser (F5) => this will load debug info
  • VS: Stop debugging (shift+F5)
  • RC project – WSP – Attach – choose w3wp.exe
  • Refresh the browser (F5) => now your breakpoint will be filled and reached

Thanx to Erik Norström.

In addition you would like to have following set in the web.config for your WebApp:

<?xml version="1.0"?>
<configuration>
  <SharePoint>
    <SafeMode CallStack="true" AllowPageLevelTrace="true">
      <PageParserPaths>
      </PageParserPaths>
    </SafeMode>
  </SharePoint>
  <system.web>
    <!--
        Enable ASP.NET debugging.
        Set compilation debug="true" to insert debugging
        symbols into the compiled page.
    -->
    <compilation batch="false" debug="true">
    </compilation>
    <!--
        The <customErrors> section enables configuration
        of what to do if/when an unhandled error occurs
        during the execution of a request.
    -->
    <customErrors mode="Off">
    </customErrors>
  </system.web>
</configuration>

2 Comments »

  1. [...] For debugging a WebPart see here. [...]

    Pingback by WSS: Development - Quick Start with WSPBuilder « RaSor’s Blog — October 24, 2008 @ 9:01 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.