Search code examples
c#json.netsignalrsignalr-hub

"Value cannot be null" when passing null arguments to SignalR client-side proxy


Using SignalR (v2.0.2) I'm getting this exception:

Value cannot be null.
Parameter name: o
   at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(Object value, String parameterName)
   at Newtonsoft.Json.Linq.JToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer)
   at Newtonsoft.Json.Linq.JToken.FromObject(Object o, JsonSerializer jsonSerializer)
   at Microsoft.AspNet.SignalR.Client.Hubs.HubProxy.Invoke[T](String method, Object[] args)

I'm calling the HubProxy with reflection, and I am passing in some null arguments that are triggering this error (aka, some items in the Object[] args are null). However, passing null for an argument to a method is a perfectly legitimate thing to do. Is this a bug in SignalR in that it is trying to serialize null parameters or is it a bug in Json.NET (v6.0.1) in that it shouldn't attempt to serialize a null object?


Solution

  • Turns out this is a known bug in SignalR that has been fixed and will be included in the upcoming 2.2.1 release. See their ticket here.