Type ‘System.Xml.Linq.XDeclaration’ 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.
System.Runtime.Serialization.InvalidDataContractException: Type ‘System.Xml.Linq.XDeclaration’ cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribu…
As an Initial Try, Check if Supports Persistence is enabled in Project Settings. If not enabled, Enable it and Check if the same error exists.
If the above doesn’t work, take a look at the Doc below which describes about the serializable variables that are allowed when Persistence activities are involved.
The issue seems to occur when you are using the forms activity can you try changing the package version of the same to some other version to debug to see if that version is having any issues?
Can you confirm if the data used while debugging and while running is same?
if not may be that might be a data issue as well.
While running the bot in debug when it fails and the bot goes to paused state please check the locals panel and see the inner exception details from the exception details in the locals panel that might give more information on why it failed
The error “Type ‘System.Xml.Linq.XDeclaration’ cannot be serialized” occurs when you try to serialize an object of type XDeclaration using the .NET Framework’s built-in XML serialization mechanism. This error indicates that the XDeclaration class is not marked with the [Serializable] attribute, which means that it cannot be serialized.
To fix this issue, you have a few options:
Use a different method to serialize the object. Instead of using the built-in XML serialization mechanism, you can use a different method to serialize the XDeclaration object. For example, you can use the XDeclaration class’s own ToString() method to convert the object to a string, and then save the string to a file or transmit it over a network.
Mark the XDeclaration class with the [Serializable] attribute. If you want to use the built-in XML serialization mechanism, you can mark the XDeclaration class with the [Serializable] attribute to indicate that it can be serialized. To do this, you will need to modify the XDeclaration class’s source code and recompile it.
Use a different XML library. Instead of using the built-in XML classes in the .NET Framework, you can use a different XML library that provides its own XML serialization mechanism. For example, you can use the System.Xml.XmlDocument class, which is marked with the [Serializable] attribute and can be serialized using the built-in XML serialization mechanism.