Aidan Garnish

Collaboration Not Competition

Creating an InfoPath installer file with Visual Studio 2008

Having created an InfoPath form project using Visual Studio 2008 and adding some code behind to the form I wanted to deploy it to SharePoint. The easiest way to do this should have been to use the publishing wizard to create an installer file. However, there seems to be a bug in Visual Studio 2008 that prevents you from selecting this option in the wizard. The message displayed is that you need VS 2003 or 2005 installed to create the installer file.

There is a way around this by using the REGFORM.exe tool found in C:\Program Files\Microsoft Office\Office12. The tool allows you to create a .js file that marks the .xsn as fully trusted so that it can be added to the managed forms collection on your MOSS farm.

First you need to go to VS and the Publish option in the Build menu. Instead of selecting the create installer option publish to a network location and create the .xsn on your file system.

Next, open up a command prompt and navigate to C:\Program Files\Microsoft Office\Office12\regform.exe.

Supply the necessary parameters - these are, the /U the URN for the form which can be found in VS, File - Form Properties - ID, /T Yes to mark the form as fully trusted (this is necessary to deploy it to SharePoint) and finally the path to the .xsn file.

You should end up with something like - regform.exe /U urn:schemas-microsoft-com:office:infopath:MyForm:-myXSD-2008-08-07T13-36-16 /T Yes C:\Forms\MyForm

Running the command will create a .bak file and a .js file in the same folder as the .xsn. Run the .js file and then open SharePoint central administration. Go to the Applications tab and under the InfoPath forms services section select Manage Form Templates.

This Microsoft article explains the rest of the process to make the form available in a site collection in detail

If you run the .js in your development environment you will need to unregister the form before you will be able to open it again from Visual Studio. To do this open the .js file in Notepad and change var fInstall = true; to var fInstall = false; - Run the .js file again and this time the message prompts will tell you the form is being unregistered. You can now run the form from Visual Studio again.

Add comment