Creating long running process - serialization problem

Hi all,

I’m developing a long running process using the UiPath.persistence.activities package version 1.0.1 (not using the latest “UiPath.persistence.activities” package version due to Orchestrator version not being the latest).
During the process I receive and process email messages using the Outlook activities. When an email with a specific subject arrives, I need to suspend the process: so I create a queue item with “Add Queue Item And Get Reference” activity, the queue item gets createc correctly. Then I have a “Wait For Queue Item And Resume” activity that throws the following exception:

19.10.4+Branch.support-v2019.10.Sha.fe819a658cad0585a64d2f8af94fad5c30b8d122

Message: Type 'System.Net.Mail.AlternateViewCollection' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.

Exception Type: System.Runtime.Serialization.InvalidDataContractException

RemoteException wrapping System.Runtime.Serialization.InvalidDataContractException: Type 'System.Net.Mail.AlternateViewCollection' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types. 
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.Activities.WorkflowApplication.IdleEventHandler.OnStage2Complete(IAsyncResult lastResult, WorkflowApplication instance, Boolean isStillSync)
   at System.Activities.WorkflowApplication.EventFrame(IAsyncResult result)

I understand the exception from a technical standpoint, but I need a workaround.
Any ideas?
Thanks,
Giovanni Romeo

You cant use non serializable objects in there as it would make it impossible to save the state…

Hi @gromeo

I came across the same scenario few weeks back… The cause was, you cannot have any application related activities in the long running workflow xaml file where you have those wait activities…
Hence, the option was, have separate workflow files to handle application related activities, and have a separate xaml file to handle the long running workflow (persistence) related activities. Having other activities in the same workflow breaks it…

Have them separately and the pass the data through arguments, or as a queue transaction item and it will work for you

7 Likes

Thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.