Debugging Web Parts

So we have a to do list that includes looking at Kerberos for CRM and SharePoint v4 as well as another that includes getting the BDC ADF File Builder to run.

But for now, we’ve had a new project dropped on us that includes reworking a web part project that never really got finished. It’s a WSS 3.0 solution so let’s see what we can do with it.

First, I have the solution file: MyProject.sln and MyProject.sou.

In Visual Studio 2008, I select Open from the File menu and select Project\Solution. In the Open Project dialog box, I navigate out to my  project folder and select MyProject.sln.

The project opens in the solution explorer. Now we have our friend, Carsten’s WSPBuilder installed in the VS environment so, when I right-click on the project, I get a WSPBuilder | Deploy option. That makes the machine run and I get a little text in the output window that ends with Done.

Now, since I’m working directly on my SharePoint server and this web part has already been deployed and is visible on a team site, I can pretty much hack it up and redepoy it and my hack will appear on the screen.

For example, I have a MyWebPartToolPane.cs file that’s got code that looks like this: 

namespace CmsFtpPublishing32bit.WebPartCode
{
    public class MyWebPart : System.Web.UI.WebControls.WebParts.EditorPart
    {

In here, we’re creating a bunch of controls and structuring them in the tool pane with alot of these:

 
 

Controls.Add(new LiteralControl("<br/>"));
Controls.Add(new LiteralControl("<div class=\"UserSectionTitle\">These Settings</div>"));
Controls.Add(new LiteralControl("These Settings<br/>"));
Controls.Add(TheseSettings);
Controls.Add(new LiteralControl("<br/><br/><div class=\"UserDottedLine\"></div>"));

Here is where we can add “Hello World” and see it in our tool pane. First, we have to do a WSPBuilder | Deploy again. Then browse to the page with the web part and open the tool pane.

Next we’ll attach the debugger to it and break into the code at runtime. Event though it was written in 2006, our new best friend, George, outlines, in this post, the process of attaching the VS debugger to your w3wp.exe process to hit your breakpoints.

hth

-robot


Tags:

 
 
 

Comments are closed.