baswegan

I have a simple form that I am using for Association in my workflow. The form works fine and I can associate my workflow to the document library. The problem comes in when I try to use the form data in my workflow. I am using the following code to import the form data into the AssociationData class.

I exported the form code, ran "xsd.exe /c /l:vb mychema.xsd" which generated the appropriate class. I am using the following code to generate my class from the form data (extra lines removed for readability):

Public Class PurchaseReqWorkflow
Public workflowProperties As SPWorkflowActivationProperties = New Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties
Public assocData As New AssociationData()

Private Sub codeActivity1_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim serializer As New XmlSerializer(associationData.GetType)
Dim reader As New XmlTextReader(New System.IO.StringReader(workflowProperties.AssociationData))
assocData = CType(serializer.Deserialize(reader), AssociationData)

The code executes fine and the assocData object is populated with correct values (viewed when debugging). The problem comes in when the workflow attempts to dehydrate and I get the following error in my sharepoint logs:

DehydrateInstance: System.Runtime.Serialization.SerializationException: End of Stream encountered before parsing was completed. at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream) at System.Workflow.ComponentModel.Activity.Load(Stream stream,...
01/23/2007 15:42:16.30* w3wp.exe (0x1318) 0x0268 Windows SharePoint Services Workflow Infrastructure 72eo Unexpected ... Activity outerActivity, IFormatter formatter) at System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity) at System.Workflow.Runtime.Hosting.WorkflowPersistenceService.RestoreFromDefaultSerializedForm(Byte[] activityBytes, Activity outerActivity) at Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId) at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId) at Microsoft.SharePoint.Workflow.SPWinO...
...eHostServices.DehydrateInstance(SPWorkflowInstance workflow)
WinWF Internal Error, terminating workflow Id# 993849ac-f594-423b-be45-abfae4290112

Now, what seems really odd about this is that if I comment out this line "assocData = CType(serializer.Deserialize(reader), AssociationData)", the workflow properly (de)hydrates. Since this is an xsd generated class that should be serializable, I am starting to get frustrated. Any help you can provide would be greatly appreciated. Thanks.

Brad Aswegan



Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

Cheung Tin Wo

I encountered a very similar problem. But one thing is different is that even I comment out the line of Deserialize() the workflow is still not working. But finally, when I find that the problem is come from the code of writing eventlog. After comment out the lines, the workflow works. But I still don't know why it is the problem.

Wo





Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

cksturton

Hi Brad,

I just encountered this issue when I moved a second task into an IfElseBranchActivity. The workflow has two tasks, each with their own edit task form and it was working correctly, but then I added an If/Else and moved the second task into the If branch and now I'm getting the SerializationException. So far I haven't been able to find the offending code. Have you learned anything about the error

Thanks

-Cynthia





Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

cksturton

It turns out I am getting this error as a result of using an invokeWebService activity. I still haven't been able to figure out what I'm doing wrong though. The web service gets invoked correctly and the next task gets created, but the workflow can't dehydrate correctly after creating the task. Have you had any luck

Thanks,

Cynthia





Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

Andreas Schnegg

Hi baswegan and ohters
I have nearly the same Problem. When I Start my Workflow , everthing is fine. The workflaw takes the IP-Initiaton-Form's Data creates a Task with a custom-IP-Form and wants to wait on Task-Chaned Event. Thenthe Workflow gets dehydrated and i get DehydrateInstance(SPWorkflowInstance workflow) - Error. I'm getting mad about this. I've another Workflow with nearly the same construction and thisone works fine, but mine is crashing and I can't fine the reaseon.
Did you find any solution to your problem or a reason why this error occures
would be extremly happy for any answer to this problem, thx!




Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

baswegan

Yes, I found a solution.

In the automatically generated class, I had to mark the following variable and non-serialized and everything was happy again. I think it has something to do with the "lang" element in an infopath template, I remember you used to have to programatically remove it before doing certain operations on infopath documents. I can't for the life of me figure out why infopath doesn't conform to xml standards, but it doesn't.

<NonSerialized()> Private anyAttrField() As System.Xml.XmlAttribute


Hope this helps.





Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

Andreas Schnegg

this was the point, thanks a lot!!



Re: SharePoint - Workflow Infopath xsd and sharepoint workflow serialization problem

MaxWeber

Great thread guys, thanks very much for posting this. This definately helped me resolve the same problem I had as well. After doing a little testing to see what exactly works and coming up with what you found, I was also wondering why it wasn't doing that before, when I was just transporting around XML. I then realized that my private workflow objects were being serialized! I figured this was using XML serialization until I looked a little closer at the log files.

Going along with adding the NonSerialized attribute to the schema-generated file, what I also found effective was to place the attribute on my private member variables representing the infopath form schema-generated objects.

For instance, my association/initiation form I was reading through workflowProperties.InitiationData (code is in C#, sorry, i hope you get the point though). The schema-generated class is "SubmitExpenses". I created a read-only property for this

Code Snippet

[System.NonSerialized]
private SubmitExpenses _expenses = null;


public SubmitExpenses expenses
{
get
{
if (_expenses == null)
{
XmlSerializer xs = new XmlSerializer(typeof(SubmitExpenses));
XmlTextReader xtr = new XmlTextReader(new StringReader(workflowProperties.InitiationData));
_expenses = (SubmitExpenses)xs.Deserialize(xtr);
}
return _expenses;
}
}

I found that when I added the NonSerialized attribute to the private member, my Dehydration issues went away.