I have a WCF service.
A normal operation will see that the server is doing some processing, returning a populated XactTaskIn object to the client using a callback. I am working fine.
My problem is that when I try to set the returnData variable to a populated XactException and try to send XactTaskIn back to the client using a callback, I get the following exception.
The exception is the "Type" XactException "with the data contract name 'XactException: HTTP://schemas.datacontract.org/2004/07/' is not expected. Consider using DataContractResolver or adding any types unknown statically in the list of known types - for example, using the KnownTypeAttribute attribute or adding them to the list of known types passed to the DataContractSerializer. " (System.Runtime.Serialization.SerializationException exception) Exception Message = "Type" XactException "with data contract name 'XactException: HTTP://schemas.datacontract.org/2004/07/' is not expected. Consider using DataContractResolver or add any types are unknown statically in the list of known types - for example, using the KnownTypeAttribute attribute or adding them to the list of known types passed to DataContractSerializer. ", Exception type =" System.Runtime.Serialization.SerializationException "
Here is the XactTaskIn class
[DataContract] public class XactTaskIn { [DataMember] public DateTime timeOut; [DataMember] public DateTime timeIn; [DataMember] public string name; [DataMember] public string responseTo; [DataMember] public String moduleFromName; [DataMember] public String moduleFromType; [DataMember] public String methodFromName; [DataMember] public object[] originalInputs; [DataMember] public String returnMethodToCall; [DataMember] public String returnModuleToCall; [DataMember] public object returnData; public XactTaskIn(DateTime timeOut, DateTime timeIn, string name, string responseTo, String moduleFromName, String moduleFromType, String methodFromName, object[] originalInputs, String returnMethodToCall, String returnModuleToCall, object returnData) { this.timeOut = timeOut; this.timeIn = timeIn; this.name = name; this.responseTo = responseTo; this.moduleFromName = moduleFromName; this.moduleFromType = moduleFromType; this.methodFromName = methodFromName; this.originalInputs = originalInputs; this.returnMethodToCall = returnMethodToCall; this.returnModuleToCall = returnModuleToCall; this.returnData = returnData; } }
Here is the XactException class:
[DataContract] public class XactException { [DataMember] string message; public XactException(string message) { this.message = message;
Update:
So, a comment from Daniel helped me.
Now it looks like the server sends a callback to the client, but the client throws the next exception.
- Caught: "The formatter made an exception while trying to deserialize the message: an error occurred while trying to deserialize the parameter http://tempuri.org/:taskIn . The InnerException message was" Error at line 1 position 960. Element 'Http: //schemas.datacontract. org / 2004/07 /: returnData 'contains data from a type that displays the name' Http://schemas.datacontract.org/2004/07/:XactException. The deserializer does not know any type that maps to this name. Consider using a DataContractResolver or add a type corresponding to โXactExceptionโ in the list of known types โ for example, using the KnownTypeAttribute attribute or adding it to the list of known types passed to the DataContractSerializer. '. See InnerException for more information. Details "(System.ServiceModel.Dispatcher.NetDispatcherFaultException) Exception Message =" The formatter threw an exception while trying to deserialize the message: an error occurred while trying to deserialize the parameter http://tempuri.org/:taskIn . The InnerException message was 'Error at line 1 position 960. The' Http://schemas.datacontract.org/2004/07/:returnData 'element contains data from a type that displays the name' Http://schemas.datacontract.org/2004 / 07 /: XactException. The deserializer does not know any type that maps to this name. Consider using a DataContractResolver or add a type corresponding to "XactException" in the list of known types - for example, using the KnownTypeAttribute attribute or adding it to the list of known types passed to the DataContractSerializer . '. See InnerException for more information. Details. ", Exception Type = "System.ServiceModel.Dispatcher.NetDispatcherFaultException"
user589195 May 27 '11 at 13:44 2011-05-27 13:44
source share