Question

I have the following

class A : ISomthing{}

Class B : ISomthing{}

interface ISomthing{}

Class C { public ISomthing _member {get;set}}

and i try to send the following object from my .net signalR client to my hub ,I'm using signalR 2.0.2

C obj = new C();
obj._member  = new A();

I receive the following error ,Could not create an instance of type ISomthing . Type is an interface or abstract class and cannot be instantiated.

In my client and server side I'm using JsonSerializer.TypeNameHandling = TypeNameHandling.Auto;

Update : The object can be serialized by it self, using the signalR serializer : var textWriter = new StringWriter(); _hubProxy.JsonSerializer.Serialize(textWriter, obj );

Was it helpful?

Solution

Apparently this is not currently supported , see my question here

And the answer I got : "The DependencyResolver has an IParameterResolver registered which is responsible for deserializing server-side inputs. The IParameterResolver is implemented by DefaultParameterResolver which does not use the JsonSerializer registered the DependencyResolver. msdn.microsoft.com/en-us/library/jj919135(v=vs.118).aspx"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top