SharePoint workflow + list item edit + value cannot be null

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:

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

That should be enough. Solution source.



Tags: , , ,

9 Responses to “SharePoint workflow + list item edit + value cannot be null”

  1. Thanks for posting this! Saved me a lot of headache :)

  2. Martin says:

    Cheers a lot for posting this!

    I cannot believe that things like these aren’t taken care of in the product…

  3. Harmeet says:

    Thanks for the post…!!

  4. Brad says:

    This post sure saved me some time and a headache. Thanks!

  5. Syed Atif Imtiaz says:

    Bundle of thanks.

  6. Joel Rotich says:

    Where is the location of this file, I am working on sharepoint designer, but I cannot seem to find the location of this elements.xml file to edit.

    Please advice

  7. This should only apply if you’re using Visual Studio to create your workflow. If you’re using SPD then it should take care of this. However, you can check, the Elements file should be in your 14 hive in the Features folder under layouts/template, I rthink

  8. Jane Wang says:

    Thanks heaps!

  9. This came at a perfect time. Thanks TONS for the post!

Leave a Reply