Use Visual Studio to create InfoPath forms… without code

Although the primary purpose of Visual Studio 2005 Tools for Office (InfoPath 2007 Support) is to add C# and Visual Basic code to your InfoPath form template, you can still take advantage of hosting InfoPath inside Visual Studio to design forms that don't have any code.
When you create a new InfoPath form template project in Visual Studio, by default, it will be created with code enabled.  To obtain a form without code, you need to explicitly remove the code from the form by using the remove code button in the programming tab of the form options dialog.
After clicking on this button, you might be confused to see that the code file is still present in the project.  Don’t worry about this.  When you build the project, the hosted designer will not add the output assemblies to the form template.
How it works
After a new project is created, the “enabled” attribute of the “managedCode” element in the manifest.xsf defaults to “yes”.  Clicking the remove code button sets this attribute to “no”.
<xsf2:managedCode … enabled="no"></xsf2:managedCode>
This attribute is set back to “yes” when you insert an event handler using the hosted InfoPath designer.
After a success build, the output assemblies will only be included with the form template when this attribute is set to yes.
- Gary
Software Development Engineer
Comments (11)

  1. Parag Khare says:

    I have Visual Studio 2005 Team Edition for Developers installed which installed the Visual Studio Tools for Office, however i get an error when i try installing: "Visual Studio 2005 Tools for Office Update: InfoPath 2007 Beta Support" which is available at the following URL:

    I also have the Microsoft Infopath 2007 Beta 2 installed.

    The error message says: "Setup cannot detect atleast one required component: matching language version of Visual Studio 2005 Team System, Professional Edition, or Tools for the Microsoft Office System, including Visual Basic or Visual C#.

    I would like to be able to develop InfoPath 2007 forms inside Visual Studio 2005.

    Let me know.

    Thank you.


  2. bkleynbok says:

    Visual Source Safe 2005 integration between InfoPath 2007 project created in VS2005 fails.

    InfoPath Form Template folder which contains files that are used inside XSN template would not go under source control.

    Check in fails for both folder and files under that folder.

    This would happen even with new solution created from XSD schema.

    Any ideas why would source control fail?

    Appreciate all the help I can get.

  3. fmueller says:

    Please close the InfoPath Designer tab, before trying to check in your solution. Also make sure that you check out the solution before you build and run it.

    – Frank

    Software Development Engineer in Test

  4. says:

    Is it possible to show, edit etc. InfoPath forms, without installed InfoPath on a machine?

    I try to create an application, that show InfoPath forms for editing etc., but with some extra work before (Login and such things).

    Thank you.


  5. infopath says:

    To mbruenjes: yes, editing InfoPath forms is possible by using a compatible browser, if you have Office Forms Services (part of MOSS 2007). You’d likely need to use the XmlFormView control as a part of your ASP.NET application.


  6. says:

    Thanks for your answer. Is there another solution for desktop applications only?


  7. infopath says:

    Michael, are you asking if there’s a way to fill out InfoPath forms in a desktop application without InfoPath installed? If so, the answer is no. Could you talk a little bit about your scenario?

    You could embed InfoPath as a web form control into your custom desktop application, but this still requires an InfoPath license.


  8. says:

    Last year i worked on a desktop application for the public health. There were great dynamic forms with dependecies and such things and it should be XML as base of that forms. The data of the filled form are shown in a PDF file with XSLT and XSL:FO.

    I used myXAML for the forms and created that as UserControls with the VS editor but this was very slow and unhandy.

    I played with InfoPath and it was exactly what i need. Dynamic forms with code behind for business logic. The company’s idea was to stay away from licenses in any kind, so i hoped i can create InfoPath forms and put them into a desktop application.


  9. infopath says:


    I bet the company already has an Office license – and InfoPath is included in another, slightly more expensive Pro Plus (and above) SKU. If you really can’t use the Forms Server in MOSS, this would be the only way out.


Skip to main content