SharePoint workflow + list item edit + value cannot be null

Thu, May 26, 2011 One-minute read

You may encounter a random error when using a custom Visual Studio SharePoint 2010 workflow. Everything appears OK, but when you go to edit the item that the workflow is running on, the EditForm fails to load and you see an error like:

`Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: s

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: s]
System.IO.StringReader..ctor(String s) +10151478
System.Xml.XmlDocument.LoadXml(String xml) +51
Microsoft.SharePoint.Publishing.Internal.WorkflowUtilities.FlattenXmlToHashtable(String strXml) +90

The problem is that you didn’t give your workflow any Association Data. So if your workflow is not actually using any association data, you need to trick SharePoint in to thinking you are. The solution is quite simple, in your Elements.xml file of your Workflow, at the same level as your MetaData element, creat:

<br /> <AssociationData><br /> <Dummy></Dummy><br /> </AssociationData><br />

That should be enough. Solution source.