Debugging Visual Studio 2005 workflows for SharePoint

Learn which steps are required to be able to set up and debug Visual Studio 2005 workflows for SharePoint.

ADVERTISEMENTS

If you’re developing a SharePoint workflow in Visual Studio 2005 on the same machine where SharePoint is running, debugging the workflow is a 5-step process:

  1. Deploy your workflow to SharePoint.
  2. Set breakpoints in your workflow code.
  3. Set the Visual Studio debugger to attach to Workflow code.
  4. Attach the Visual Studio debugger to the w3wp.exe process for the SharePoint server to which the workflow has been deployed.
  5. Perform actions in SharePoint to run the workflow and have the code break in the debugger.

Set the Visual Studio debugger to attach to Workflow code

To set the Visual Studio debugger to attach to Workflow code:

  1. In Visual Studio 2005, on the Debug menu, click Attach to Process.
  2. On the Attach to Process dialog box, click Select behind the Attach to text box.
  3. On the Select Code Type dialog box, select Workflow in the Debug these code types list box, and click OK.

    Attach to Workflow code to debug a SharePoint workflow in Visual Studio

    Figure 1. Attach to Workflow code to debug a SharePoint workflow in Visual Studio.

Attach to the w3wp.exe process for SharePoint

While you could attach the Visual Studio debugger to all of the w3wp.exe processes listed in the Available Processes list box on the Attach to Process dialog box, if you want to attach the debugger to only one process, you could use the following method to find the right process to attach to:

  1. Open a command-line window.
  2. Navigate to the c:\windows\system32 directory.
  3. Type iisapp.vbs and press [Enter].

A list of application pool names and process IDs will be displayed. You can then choose the process ID that corresponds to SharePoint and then in Visual Studio, attach the debugger to this process ID.

Finding the process ID for the worker process of the SharePoint application pool

Figure 2. Finding the process ID for the worker process of the SharePoint application pool.

Debug the SharePoint workflow in Visual Studio

Once you’ve selected the correct process ID for the worker process of the SharePoint application pool from the Available Processes list box on the Attach to Process dialog box, you can click Attach to start the debugging session.

And once you’ve started the debugging session, you must go to SharePoint and perform actions that will cause your workflow to run.

Your workflow should hit the breakpoints you’ve set previously and break in the debugger in Visual Studio. If your breakpoints are not being hit, double-check whether you’ve correctly deployed the DLL for your workflow to the GAC. This includes checking for any typing errors in the values for the CodeBesideClass and CodeBesideAssembly attributes in the workflow.xml file.

Related Articles

ADVERTISEMENTS