How to: Debug Browser-Enabled Forms Deployed on InfoPath Form Services
To debug business logic for browser-enabled forms deployed to InfoPath Forms Services from Microsoft Visual Studio 2005 with Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System or Visual Studio 2008 with Visual Studio Tools for Office, you must manually attach the debugger to the server process (w3wp.exe) and follow a similar process to that used for debugging Web Parts or ASP.NET applications.
Business logic code for a browser-enabled form template is deployed and loaded on the server from one or more assemblies. The following information assumes that you are using a standalone installation that has a single Web front end and that you have opened an interactive session as an Administrator. Remote debugging is also possible by following the guidelines for Remote Debugging Setup and then following the procedures described below.
Building the Form Template for Debugging
To debug the form template business logic assemblies on the server, the compiler must be configured to generate and store debugging and project state information in debug symbols files (.pdb), which must then be available on the server. If the form has been developed using Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System, this will occur when you build a Debug configuration, which is the default configuration for an InfoPath Form Template project. For a Release configuration, the debugging information is not generated by default. To change this, right-click the project in Solution Explorer, click Properties, click Build, click the Advanced button, and then select full from the Debug Info drop-down list. In both of these cases, Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System will generate a form template .xsn file and the proper entries in the form manifest file so that the .pdb files are automatically deployed and loaded on the server. (To change build configuration settings, use the Configuration Manager command on the Build menu.)
The user performing the debugging operation must also have access to the source code for all business logic assemblies associated with the form template. The source code is not included in the form template itself (it is contained in the form template project folder) and should be made available by the form designer.
Attaching the Debugger
Before you can start debugging, you must attach to all instances of the server process (w3wp.exe) as described in the following steps.
To attach the debugger to the server process
Open Visual Studio and click Attach to Process on the Tools menu.
Click Select, click Debug these code types, select the Managed check box. and then click OK.
Select the Show processes from all users and Show processes in all sessions check boxes.
Attach the debugger to all instances of the w3wp.exe process listed in the Available Processes list box.
Executing and Debugging Code
There are two times when form template business logic is executed: at deployment and at runtime. From the debugging perspective, they both behave in a similar way. After the debugger is attached, you can debug either scenario:
To debug a deployment scenario, try to upload a form template from the Central Administration / Application Management / Manage Form Templates user interface on the server.
To debug a runtime scenario, access the form by opening it from the URL it was deployed to or using the InfoPath user interface.
All Visual Studio debugging support will be available and common tasks like setting breakpoints, stepping through the code, inspecting variables and the call stack, should work as usual. When debugging the form code, it is useful to enable Exception Handling Debugging so that the debugger will break on any abnormal situation encountered during code execution.