my client got the following callback contract:
[ServiceContract]
interface IEvent
{
[OperationContract(IsOneWay = true)]
void OnEvent(string serverName, string changeType, List<myObject> myObjects);
}
and got a class implementing IEvent as following:
class myClass : IEvent{
public void OnEvent(string serverName, string changeType, List<myObject> myObjects)
{
MessageBox.Show(@"Event Called: " + changeType + @" occured at: " + serverName + @" got " + myObjects.Count + " myObjects!");
}
}
my server got the following publishing code:
methodInfo.Invoke(client, new object[] {serverName, changeType, myObjects});
When I use methodInfo.Invoke with myObjects = new List<myobject>(){}
all works fine meaning myClass.OnEvent is called when server uses methodinfo.invoke
and mbox is displayed
BUT
when I try to send myObjects = new List<myobject>(){new MyDerivedObject()}
it doesn't work meaning myClass.OnEvent is NOT called when server uses methodinfo.invoke
and mbox is NOT displayed
both server and client contain references to myObject DLL that has both myObject and MyDerivedObject MyDerivedObject is of course derived from myObject
Help please
The example that @eugene gave can also be applied to a service contract, so in your case you could apply the ServiceKnownType to the callback contract.
[ServiceContract]
[ServiceKnownType(typeof(MyDerivedObject))]
interface IEvent
{
[OperationContract(IsOneWay = true)]
void OnEvent(string serverName, string changeType, List<myObject> myObjects);
}