I have a WSE 3.0 based web service, and a WinForms client application that makes use of the types defined in that service's References.cs, but subclasses them to provide some additional functionality required by the client.
However, when I pass an instance of the subclass back to the web service, even though I explicitly cast back to the original type, I get the dreaded:
Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
in reference to my derived type.
Code summary:
public class DefinedInReferenceCs
{
// ...
}
public class ClientSubclass : DefinedInReferenceCs
{
// My extra stuff
}
public class MyClient
{
public CallTheWebService(ClientSubclass obj)
{
// obj is an instance of ClientSubclass, cast as DefinedInReferenceCs
svc.MyMethod((DefinedInReferenceCs)obj);
// Throws an exception complaining that ClientSubclass is not statically known
}
}
I can get around this by explicitly creating a DefinedInReferenceCs instance and performing a deep copy of the relevant fields. Is there a better way?