I have a BaseModel
and a ChildModel
in my namespace. I had operations in DomainService returning both of them, and was getting an exception that said 'apply KnownTypeAttribute' to the base class. I applied, it worked.
But, if I don't expose any operation returning DerivedType in my DomainService, then also I am bound to apply this Attribute on the BaseModel, otherwise I get the exception.
Can anybody explains why is this happening ?
public class MyService: DomainServiceBase
{
public BaseModel Get()
{
return new BaseModel();
}
}
This will happen if WCF gets a message which uses the derived type. In this case since you have not used the known types attribute, WCF will not know where to find this child domain type, and throe an exception.