I am using a combination of WCF and SignalR for a project I am working on.
The WCF service has a number of DTOs that it brings over just fine because they are part of an [OperationContract]
(either as a parameter or return type).
However, I have two classes (MachineStatusDto
and DeviceStatusDto
) that are only used as return types for broadcasts from the server via SignalR:
machine.On<MachineStatusDto>("Update", m => UpdateMachineRecord(m)); //On client side
I could obviously just make a method on my WCF service that uses these types but I feel like there should be a way to inform the WCF service to include specific types, even if they aren't part of an [OperationContract]
.
EDIT:
In the end, if you just add [ServiceKnownType(typeof(SomeDto))]
to your WCF ServiceContract interface, it'll know to send over those classes in addition to the ones that are explicitly used in the Service Contract. Simple as that.