Thursday, May 5, 2011

Deploying InfoPath 2010 forms for custom workflow with SharePoint 2010 and Visual Studio 2010

I've spent a little time recently structuring a solution in Visual Studio and TFS for an upcoming project that relies heavily on workflow. There are a couple of nuances that I thought I'd document given that the information out there at present seems fragmented at best.

The aim of this blog post is to provide guidance on how to structure a Visual Studio 2010 SharePoint workflow project that includes the deployment of InfoPath forms. This article will not repeat advice which is already in abundance that relates to core workflow development concepts. I assume you're familiar with writing custom workflow in Visual Studio 2008 and MOSS 2007.

Above we see the default solution structure for a state machine workflow.

Add a new Module named "InfopathForms"

You can remove the "Sample.txt" placeholder file. When you do this, notice that Elements.xml for the module will update automatically.

Add your InfoPath form to your InfopathForms module

Double check to ensure that the "Deployment Type" property of your InfoPath form is set to Element File and that the path is "InfopathForms\".

Your elements .xml file should now look like the following

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

<Elements xmlns="">

<Module Name="InfopathForms">

<File Path="InfopathForms\InitiationForm.xsn" Url="InfopathForms/InitiationForm.xsn" />



By default, your feature.xml will look like the following:

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

<Feature xmlns="">


<Property Key="GloballyAvailable" Value="true" />



Now we need to modify our feature.xml to register the location of the forms we want to use and set the correct feature receiver. If you were used to using VSeWSS when developing workflows for MOSS 2007, these steps will have been undertaken for you automatically, you may have had to do little more than modify the path for the RegisterForms property below.

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

<Feature xmlns="" ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"



<Property Key="GloballyAvailable"Value="true" />

<Property Key="RegisterForms" Value="InfopathForms\*.xsn"/>



There are two additions here. The first is:

<Property Key="RegisterForms" Value="InfopathForms\*.xsn"/>

This tells our feature the location of the forms we want to deploy. In this case it is all of the .xsn files within the InfopathForms module.

The second modification is the feature receiver assembly and class:

ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c"


This is necessary in order for the forms to be present within the "Manage Form Templates" screen within Central Administration and is a necessary precursor to making your forms "Workflow Enabled".

At this point there is a ton of other work you need to do around building your workflow, registering your form URNs within the workflow elements file and any deserialization activities you need to do in order to take data from your initiation or association form into your workflow. None of this information is repeated here and I would point you towards MSDN and the numerous blog articles out there on these subjects.

Once you've deployed your solution, your form should now be registered in the correct location. Below we can see our IniitationForm at the top of the list within Central Administration.

Using Modules in this way to manage form templates means we simply need to drag and drop new xsn files into our Module and they will be automatically deployed with our solution. We still of course need to modify the workflow elements file to register the URNs etc but it's one less thing to think about and certainly makes deployment easier.

I hope you've found this article useful and that it saves you some time when transitioning from workflow development using VSeWSS in MOSS 2007 to Visual Studio 2010 with SharePoint 2010. Thanks for reading.


  1. Nice post, and very clear on the subject matter.

    I have been working towards a workflow that uses InfoPath for its task edit forms. I believe my solution has everything set up as required. The form deploys as workflow enabled to Central admin, however, when it comes to editing a task. The page tries to load but returns an error:

    "There has been an error while loading the form."
    "Object reference not set to an instance of an object."

    I have no idea what is wrong, I don't think the form is causing the issue as I have tried with an empty form with the same results.

    Have you seen anything like this previously, and might be able to make some suggestions as to how I progress?

    Thanks in advance,


  2. Hey Grant,

    Thanks for your comments.

    There's two things I'd check first of all.

    Firstly, check that the Form URN you have specified is that of your published form, not the initial form.

    Secondly, are you using a secondary data connection (and as such ItemMetadata.xml as a resource file)? If so, double check that you've got the schema matched up exactly right.

    Let me know if this doesn't resolve it, and best of luck.