I have an asynchronous WCF server (I’ve derived my own clientbase class) and I call this from my client application.
However, when this method is called:
public IAsyncResult Beginxxx(string path, AsyncCallback callback, object state)
{
return Channel.Beginxxx(path, callback, state);
}
I get this exception:
{“There was an error while trying to serialize parameter http://tempuri.org/:callback. The InnerException message was ‘Type ‘System.DelegateSerializationHolder+DelegateEntry’ with data contract name ‘DelegateSerializationHolder.DelegateEntry:http://schemas.datacontract.org/2004/07/System’ is not expected. Add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.’. Please see InnerException for more details.”}
If I had my own class with its own properties, this exception would make sense but this is a standard .NET type (AsyncCallback I believe the exception is complaining about). A code sample of what I am trying to do doesn’t have this problem (and I changed that to the same type of binding I am using – named pipes).
What is wrong?
You likely forgot to add the (AsyncPattern = true) property in the [OperationContract] attribute. The example below shows two clients, one (wrong) with the exact error you’re seeing, one (correct) which works. The only difference is the AsyncPattern = true in the operation contract.