Deploying browser-enabled InfoPath form with code behind i.e. .DLL as content type

Deploying an InfoPath form with code behind i.e. dll as site content type and making the debugging experience for a developer seamless.

First of all let me link a nice post by Sahil Malik for deploying InfoPath forms as content types here

Let’s create a regular SharePoint feature to deploy an InfoPath form with its element.xml and feature.xml files then we will add the xsn file and its dll in a seamless way for debugging experience for developer to be smooth.

This how the solution would look like as below:


Now we need to add the project file of the InfoPath code behind i.e. for C#


Solution with the added project of the InfoPath Form’s code behind and it would launch a conversion prompt, just click next…next and finish and you will something like this below:




Now go to the properties of the InfoPath project added into the solution and add the below line to post build events :

xcopy "$(TargetFileName)" "$(SolutionDir)TimeSheetForm\12\TEMPLATE\FEATURES\TimeSheetForm\" /y

So essentially what changes for different form is the folder under features i.e. TimeSheetForm


On the solution explorer click on show all files and you will see that under the feature folder dll appears i.e. timesheet.dll


Click on include the dll i.e. timesheet.dll to the project


Now we need to do some settings before we publish the actual InfoPath Form

Go to the Tools—> Form Options—>Category—>Security and Trust


Now select “Full Trust” and select the checkbox “Sign this form template”


Click on “Create Certificate” and select the created certificate and click “Ok”

Now we need to publish to a network location i.e. under $solutiondir\TimeSheetForm\12\TEMPLATE\FEATURES\TimeSheetForm\

For XSN to be accessible under features folder

Select the form to be published “To a network location”


On Clicking next select the location from the browse button as “C:\timesheet\TimeSheetForm\TimeSheetForm\12\TEMPLATE\FEATURES\TimeSheetForm\timesheet.xsn”


Click Next and on the next screen would look like something below:


Make sure that you delete everything inside the textbox before browse button and it should look like below:


Click on “Publish” on the next screen:


After all the steps above its time to check the features folder in the solution where we had the InfoPath code behind project and the project to deploy InfoPath form as content type


We don’t see the xsn and we will do the same as we did for the timesheet.dll

Click on show all files and include file…


Now first we will go check element.xml and it should look like something below where you have the actual published xsn file included in the element.xml

<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="">

    <Module Name="XSN" Url="FormServerTemplates" RootWebOnly="TRUE">

        <File Url="timesheet.xsn" Name="timesheet.xsn" Type="GhostableInLibrary"/>




Now we have to check the feature.xml file as to have elements

1. timesheet.xsn

2. And timesheet.dll

are included correctly in ElementManifests

<?xml version="1.0" encoding="utf-8" ?>

<Feature xmlns=""


         Title="TimeSheet Form"

         Description="This feature deploys the browser enabled TimeSheet Form."





         ReceiverAssembly="Microsoft.Office.InfoPath.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" >


        <ActivationDependency FeatureId="C88C4FF1-DBF5-4649-AD9F-C6C426EBCBF5"/>



        <ElementManifest Location="element.xml"/>

        <ElementFile Location="timesheet.xsn"/>

    <ElementFile Location="timesheet.dll"/>



        <Property Key="FeatureName" Value="TimeSheet Form Template Feature"/>




The post build script install.bat would be as below

@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"

@SET GACUTIL="c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe"

@SET WSPPBUILDER="C:\Code\WspBuilder\WspBuilder.exe"



Echo Creating Solution Package

%WSPPBUILDER% -outputpath solution -Excludepaths bin


Echo Retracting Solution

%STSADM% -o retractsolution -name TimeSheetForm.wsp -immediate

%STSADM% -o execadmsvcjobs


Echo Deleting Solution

%STSADM% -o deletesolution -name TimeSheetForm.wsp


Echo Adding Solution

%STSADM% -o addsolution -filename Solution\TimeSheetForm.wsp


Echo Deploying solution

%STSADM% -o deploysolution -name TimeSheetForm.wsp -immediate -allowGacDeployment -force 

%STSADM% -o execadmsvcjobs


Echo Resetting IIS


Now it’s time to rebuild the solution and wait for STSADM to deploy the solution…

1. Next steps are to create a form library and add the timesheet content type to the form library. Make sure that you Activate the Site Collection Feature

2. select “Management of Content Types” from the Advanced Settings of the form library on your site.

Then only you would see option for “Add from Existing site Content Types”

I will be lazy and would skip the steps which you can google and find it easily.

Let’s see how the debugging experience is enhanced by this process as my form is open on the site and I need to do some action to trigger debugger.

I would click on the “OK” button for my code to trigger , but before I do that I would attach my solution to the w3p.exe




The debugger hits the breakpoint I had set on the code


A few things to note:

· Anytime you change code behind in the solution rebuild the solution first.

· Then publish the InfoPath form to the features folder….

Let me know any feedback for improvement…I was doing save as source files but found this approach more suitable in terms of development, debugging and deployment.

9 Comments on “Deploying browser-enabled InfoPath form with code behind i.e. .DLL as content type”

  1. Mehul Bhuva March 11, 2010 at 3:20 pm #


    Nice post.

    I have also written a step-by-step comprehensive post on Deploying browser enabled InfoPath forms as Content Type, visit:

  2. Mukesh Bhavnani July 21, 2011 at 1:47 am #

    Great Post…thnx…

    Can u post for 2010…

  3. 4C Consulting Pvt. Ltd. July 21, 2011 at 1:49 am #

    Can u post for 2010…

  4. ceulmarking July 21, 2011 at 1:52 am #

    Great Post….

  5. nagaraj January 30, 2012 at 7:23 am #

    could you please post the same in vs2010 bcz its different from whatever your showed here

  6. Nagaraju March 28, 2012 at 6:42 am #

    Nice post

  7. latest web design news April 15, 2012 at 6:57 pm #

    Great stuff at this site, perfectly delivered and straight to the point.

  8. Krzysztof Kozłowski April 24, 2012 at 5:58 am #

    Ive problem with converting IPformCode.
    Conversion Report –
    The operation could not be completed. Taki interfejs nie jest obsługiwany.
    (that interfece couldnt be serviced)

    Your project is targeting .NET Framework 2.0 or 3.0. If your project uses assemblies requiring a newer .NET Framework, your project will fail to build. You can change the .NET Framework version by clicking Properties on the project menu and then selecting a new version in the ‘.NET Framework’ dropdown box. (In Visual Basic, this is located on the Compile tab by clicking the ‘Advanced Compiler Options…’ button.).

  9. Sonu July 4, 2012 at 6:28 am #

    Hi great post
    but I have so many forms and i dion’t want to publish mannually, is it possible to publish all forms in sharepoint?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: