locked
Unhandled exception during list item edit. RRS feed

  • Question

  • Hello,

    I've got strange problem with my custom workflow. I use SharePoint 2010 standard. With SharePoint designer I've created simple list. I can use it without a problem: add, delete or edit items on the list. Now for this list I've created custom workflow with VSTO. In some cases I use VSTO component "onWorkFlowItemChanged" to monitor changes made to list element. The problem is that if workflow is active for this list element and I would like to edit it I get null exception like below. I just can display it.   I’m not sure what’s wrong. Is it kind of bug?   Or I make something wrong?

    Thanks for any suggestion.

    Regards

    Tomasz

     

    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

       Microsoft.SharePoint.Publishing.Internal.WorkflowUtilities.DoesWorkflowCancelWhenItemEdited(String associationXml) +12

       Microsoft.SharePoint.Publishing.WebControls.ConsoleDataSource.EnsurePageNotInLockingWorkflowIfInEditMode() +207

       Microsoft.SharePoint.Publishing.WebControls.ConsoleDataSource.LoadDataSource() +199

       Microsoft.SharePoint.Publishing.WebControls.ConsoleDataSource.OnLoad(EventArgs e) +98

       Microsoft.SharePoint.Publishing.WebControls.XmlConsoleDataSource.OnLoad(EventArgs e) +201

       Microsoft.SharePoint.Publishing.WebControls.PublishingSiteActionsMenuCustomizer.OnLoad(EventArgs e) +186

       System.Web.UI.Control.LoadRecursive() +66

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Control.LoadRecursive() +191

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

     


    ---------------------- Tomasz Szulczewski
    Wednesday, February 2, 2011 3:02 PM

All replies

  • Same EXACT thing here. I have workflow (not from VSTO). I just created it within Visual Studio.  I am not capturing the workflow on item changed. I am tracking the OnTaskChanged. 
    Friday, March 11, 2011 3:38 PM
  • Just found the answer and wanted to update this to help out someone else..

    Add this to your elements.xml for the workflow.

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

    Friday, March 11, 2011 4:13 PM
  • Thank you so much

    if you insert your research link it was so good , why with this code problem solved?

    Tuesday, March 29, 2011 6:42 AM
  • Hello!

    Recently I've faced this issue, after migration of our SP 2007 application to SP 2010. The exception is thrown because SharePoint 2010 expects that the AssociationData element is a valid xml. Adjusting of AssociationData with a fake xml string helps only for applications created after modifications have been made. And, probably, helps for workflow instances started after the modifications. But it affects neither the live applications nor the started workflow instances. Also there are applications which don't have an usual workflow definition. I described the sufficient solution in my blog - Workflow + List Item Edit Form = Value cannot be null Exception. Briefly, I had to create a console app, which modifies AssociationData through the SP object model. You can download the console app sources from the blog post as well. Two basic methods look like:

    public static void AdjustAssociationData(SPWorkflowAssociation workflowAssociation, SPWorkflowAssociationCollection collection)
    {
        if (!IsValidXml(workflowAssociation.AssociationData))
        {
            string newValue = string.IsNullOrEmpty(workflowAssociation.AssociationData)
                                    ? "<Data />"
                                    : string.Format("<Data>{0}</Data>", workflowAssociation.AssociationData);
            workflowAssociation.AssociationData = newValue;
            collection.Update(workflowAssociation);
        }
    }
     
    public static bool IsValidXml(string str)
    {
        if (!string.IsNullOrEmpty(str))
        {
            try
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(str);
                return true;
            }
            catch {}
        }
        return false;
    }
    I hope it'll save time for somebody.


    .Net Follower (http://dotnetfollower.com)

    Thursday, April 26, 2012 2:42 AM