Home > InfoPath2010, SharePoint 2010 > How to debug Infopath2010 using VS2010

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 :).

  1. March 17, 2011 at 11:12 pm

    Thanks…this is brilliant. I’ve been looking everywhere for this process. It’s amazing that Microsoft doesn’t yet support building InfoPath Managed Code with VS 2010.

  2. c.b.
    March 26, 2011 at 5:45 am

    What kind of project template did you use to create the VS2010 project? I don’t see any InfoPath project template other than an “InfoPath Add-in” when I attempt to create a new project in VS2010.

    \cbf

    • ybbest
      March 26, 2011 at 9:23 am

      There is no such template in VS2010.But you can open the FormCode.cs file you would like to debug in Visual studio 2010(just the file not the whole project) and attach the process in vs2010.

  3. November 3, 2011 at 3:54 pm

    what i encountered an error in my code (ex. typo etc) and the code thrown an exception, should I repeat all the steps?

    • ybbest
      November 3, 2011 at 4:11 pm

      I guess you need to redeploy your Infopath form and re-attach the w3wp.exe process see if it will hit your break point.If not , you have to repeat all the process unfortunately.

  1. No trackbacks yet.

Leave a comment