Search code examples
c#linqentity-frameworkserializationworkflow-foundation

Windows Workflow Serialization Error


I am debugging a Windows Workflow workflow. The workflow has a two ReceiveSendReply activities in it. The first one is working as expected. When the second Receive is executed I get the following error:

Exception:Thrown: "Type 'System.Data.Linq.EntitySet1[DataType]' 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) A System.Runtime.Serialization.InvalidDataContractException was thrown: "Type 'System.Data.Linq.EntitySet
1[DataType]' 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."

The type 'DataType' is a class generated by EntityFramework and is not even used in the workflow. I don't understand what this message is trying to tell me, so I really don't even know where to start debugging it.

Any help would be appreciated.


Solution

  • It turned out to be that I was unintentionally returning an EF class from a code activity. The Type that the error was complaining about was a property of the EF class that was being returned, so that is what made it difficult to find.