How to debug Infopath2010 using VS2010
In InfoPath 2010 , you can only use VSTO to write code for your form. However , when you try to debug you will see no attach to process option in the VSTO Project. In order to debug your InfoPath form , you have to do the following steps and debug using Visual Studio 2010. However , if you are not using InfoPath form services with SharePoint2010 and only using InfoPath Filler , you can see how to debug here.
1. You need to go to VSTO Project properties >> Build >> Advanced option >> Set the debug info to Full. (As shown below.)
2.Republish your form,this will rebuild your VSTO Project using the new build configurations.
3. Deploy the infopath form from the central admin and activate your form template to a site collection. If you have already deployed the form before , you need to do some clean up steps :
a.Delete all the infopath forms from the form library where you use your infopath form template as a content type
b.Remove the contentType from this form library
c.Deactivate the contype feature from the site collection features.
d.Delete the infopath form template from the central admin
e.Upload the new form template from from the central admin , you need to uncheck Upgrade the form template if it already exists
f.Activate the form template to the site collection and asscociate the contentType with your form library again.
If the Above steps does not work , you need to delete the site collection and create a new one.
4. Open the FormCode.cs file you would like to debug in Visual studio 2010(just the file not the whole project),attach the w3wp.exe processes and set a breakpoint in the FormEvents_Loading event. Now if you add a new form to the form liabrary , the breakpoint should be hit.(See screenshot below)
As mentioned above , if it does not hit.You might need to delete the site collection and create a new one.Delete the form template and reupload it again remember to uncheck Upgrade the form template if it already exists .Then you should be able to debug your infopath form.I do not see why debugging in InfoPath2010 is so much harder,but here we go.Happy SharePointing and InfoPathing :).