System.IO.FileInfo cannot be serialized - Wait for Form Task and Resume

This worked fine until I converted to Windows compatibility. Now during execution when it gets to the Wait for Form Task and Resume activity, I get this exception:

System.Exception: Type 'System.IO.FileInfo' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.

After doing some research I think I understand what the error means:

  • All variables used in the scope of a long-running activity must be serializable. Types of variables listed in this page are serializable: Text, True or False, Number, Array, Date and Time. Data Table and GenericValue variables.

This appears to be trying to explain the solution:

  • Variables used in scopes that do not contain long-running activities are not subjected to the serialization requirement, as the workflow does not get suspended in their scope. Non-serializable data types can be used in separate sequence scopes in the same workflow or by invoking other files, as long as they are between Wait and Resume activities, like Wait for Job and Resume, Wait for Queue Item and Resume and Wait for Form Task and Resume.

…but I’m not really sure what it means I have to do.


This means you need to move your fileinfo related variables or non serializable variables to a separate scope …wait for resume can be included in a separate sequence and the scope of any of those variable syou are using which are not serializable can be kept in a different scope and pass only string or basic datatypes into sequence containing wait for resume

Rearranging would do the job


I need those variables to persist after the Wait. I can’t just write an entire automation with those few datatypes. It worked fine in Windows Legacy. UiPath has made a mess with this Windows compatibility stuff.