Unlike typical SharePoint 2010 development with Visual Studio 2010, debugging browser based InfoPath 2010 forms code is never easy. InfoPath custom coding requires specific software like VSTA (Microsoft Visual Studio 2005 Tools for Applications) to write custom code and one of the biggest limitations of the VSTA is it doesn’t support attaching debugger. Without VSTA supporting inbuilt debugging of InfoPath Code, you have to go through series of manual workarounds to debug the code.
Although Microsoft has documented detailed blog on the InfoPath team blog on how to debug InfoPath forms code, there are several details missing and it may become frustrating experience if you can’t hit the breakpoint while debugging InfoPath 2010 code. There are couple of clarifications Microsoft blog is missing including setting correct compile settings in the visual studio configuration manager. Without correct configuration manager setting as Active(Debug), even though project settings display debug for build settings, VSTA compiles code in the release mode which would further frustrate the developer if breakpoint never gets hit during debugging.
Based on lessons learned, I have finally decided to write detailed step by step blog to debug InfoPath 2010 Forms using Visual Studio 2010. Please keep in mind that to debug the browser based InfoPath forms, you will have to attach the SharePoint process in the Visual Studio, not Visual Studio Tools for Applications. Any version of Visual Studio is fine – VS 2005, VS 2008, or VS 2010.
Microsoft Resources
Here are the high level steps.
Step 1 – Ensure the InfoPath Form Template is compiled in the Debug Configuration so the XSN includes the symbol (PDB) file.
You must configure Visual Studio Tools for Applications (VSTA) to build PDB files for your form solution by outputting full debug information.
Step 2 – Publish the InfoPath Form and verify that XSN file contains the debugged version of the compiled code.
Rename the XSN files to the CAB file to extract the InfoPath Form Template files and it should contain the debug version of the DLL and PDB files
Step 3 – Deploy the Debugged Version of InfoPath Form Templates to the SharePoint 2010
Step 4 – Debug the InfoPath Form Code through Visual Studio, not VSTA
Hope this helps to clarify the steps needed to debug the InfoPath 2010 code deployed to the SharePoint 2010 environment.