Unexpected Type - Serialization Exception

Solution 1:

In your class

    [DataContract]
    public class XactTaskIn

you have properties that return objects:

        [DataMember]
        public object[] originalInputs;

        [DataMember]
        public object returnData;

WCF needs to know ahead of time what types can possibly be in there, so that it can tell the client (through the WSDL) what all the types are. For any/all non-'native' types (anything that isnt int, string, DateTime, etc) you will need to add a [KnownType] attribute for every possible type that might be passed back in those object properties, like this:

    [KnownType(typeof(XactException))]
    [KnownType(typeof(...))]
    [KnownType(typeof(...))]
    [DataContract]
    public class XactTaskIn

That way when WCF builds the WSDL for the service, it will know to add XactException to the list of datatypes, and also the serializer will know to look for those classes.


Side-note; if your client was built using SrvUtil, Service Reference, or generated from the WSDL in some way, you will need to rebuild the client after adding the [KnownType] attributes!