Debugging InfoPath forms in the client environment is relatively simple: set a breakpoint, press F5 and execute the process that will cause the breakpoint to be hit. However, debugging InfoPath forms that are opened in the browser requires some additional steps:
1) Ensure the InfoPath Form Template is compiled in the Debug Configuration so the XSN includes the symbol (PDB) file2) Open the local copy of the code file in Visual Studio and set a breakpoint3) Attach to the appropriate w3wp process4) Execute the process that will cause the breakpoint to be hit
So let’s take a look at each step individually.
Step 1: Ensure the InfoPath Form Template is compiled in the Debug Configuration so the XSN includes the symbol (PDB) file
1) Open the InfoPath Form Template in Design View2) Open the Code Editor3) From the Project menu choose “<ProjectName> Properties”4) Insure the Configuration option is set to Active (Debug)
NOTE: If you do not see the Configuration option make sure the “Show Advanced Build Configurations” option is enabled: Tools | Options | Projects and Solutions | General
5) Build and save the project6) Publish the Form Template to your Microsoft Office SharePoint Server
NOTE: If you want to make sure the XSN you are publishing includes the symbol (pdb) file, save the XSN as Source Files and review the resulting files to make sure there is the .pdb file.
Step 2: Open the local copy of the code file in Visual Studio
1) Launch Visual Studio 20052) Open the code file (i.e. FormCode.cs) from the project files folder for your Form Template3) Set a breakpoint
Step 3: Attach to the appropriate w3wp process
1) Open Internet Explorer and navigate to your site2) From the Debug menu in Visual Studio choose “Attach to Process…”3) For the “Attach To” option make sure this has at least “Managed code” – if not, click the Select button to enable Managed Code4) Select the correct w3wp process and click Attach
NOTE: Determining the correct w3wp process can be a bit tricky. To isolate the correct process: - From the server machine, open a command prompt- Navigate to the System32 directory and run the following script: iisapp.vbs. This script will list all the currently running w3wp.exe processes, listing their PID and associated application pool id. The application pool id is the only relation between the pid and your application.- Use the PID to identify the correct w3wp.exe on the “Attach to Process” screen.
Step 4: Execute the process that will cause the breakpoint to be hit
1) Open your form in the browser and execute the process that will cause the code to run – execution should stop when it hits your breakpoint!
Scott HeimSupport Engineer
Last week, we posted an article on techniques around debugging browser forms. We received a few questions
I couldn't get the Debug config setting to "stick", it kept going back to Release (confirmed when I looked at the Source). The trick is to go to Build menu -> Configuration Manager, and set the Active solution configuration to Debug, I also set the Configuration on the grid on that same screen to Debug. One of these worked and my code compiled as Debug. This is all under the Visual Studio Tools for Applications screen.
I was able to debug the InfoPath 2010 form code...
Here are the steps (under the Visual Studio Tools for Applications)
1. Go to Tools -> Options -> Projects and Solutions -> General -> Show advanced build Configirations.
2. Then Navigate to Build -> Configuration Manager. (here you can set the debug settings)