Serializing abstract class over WCF with subclasses in different assemblies
We are using C# and .NET 4 to build an WCF-enabled application. We have a
"parent" assembly that implements:
[DataContract]
public abstract class A
{
//...
}
Then, other "child" assemblies implement subclasses of A, like this:
[DataContract]
public class B : A
{
//...
}
In another assembly we have some methods that we are trying to encapsulate
as WCF services. Some of these methods have a return type of A.
Evidently, child assemblies need to include a reference to the parent
assembly in order for derived classes to inherit from class A. The problem
arises when WCF seems to demand that we add KnownType attributes to class
A to list all its potential subclasses; this would need that the parent
assembly where A resides had references to the child assemblies, which
would create circular dependencies.
Is there any other way around this? Does WCF really need to know the types
of all the potential concrete classes of an abstract class that is being
used as a return type? Thank you.
No comments:
Post a Comment