SignalR/SignalR · error · ArgumentNullException
method
Error message
method
What it means
Thrown by HubProxy.Invoke<TResult,TProgress> when the method parameter is null. The method name identifies the server hub method to call, so a null name cannot be serialized into the hub invocation envelope and is rejected before any network activity.
Source
Thrown at src/Microsoft.AspNet.SignalR.Client/Hubs/HubProxy.cs:89
return Invoke<object>(method, args);
}
public Task<T> Invoke<T>(string method, params object[] args)
{
return Invoke<T, object>(method, onProgress: null, args: args);
}
public Task Invoke<T>(string method, Action<T> onProgress, params object[] args)
{
return Invoke<object, T>(method, onProgress, args);
}
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions are flown to the caller")]
public Task<TResult> Invoke<TResult, TProgress>(string method, Action<TProgress> onProgress, params object[] args)
{
if (method == null)
{
throw new ArgumentNullException("method");
}
if (args == null)
{
throw new ArgumentNullException("args");
}
var tokenifiedArguments = new JToken[args.Length];
for (int i = 0; i < tokenifiedArguments.Length; i++)
{
tokenifiedArguments[i] = args[i] != null
? JToken.FromObject(args[i], JsonSerializer)
: JValue.CreateNull();
}
var tcs = new DispatchingTaskCompletionSource<TResult>();
var callbackId = _connection.RegisterCallback(result =>
{View on GitHub (pinned to 693053b89a)
Solutions
- Pass the exact server hub method name (a non-null string) to Invoke.
- If the name is dynamic, validate it is non-null and non-whitespace before invoking.
- Confirm the method name spelling/casing matches the public method on the Hub subclass.
Example fix
// before
await proxy.Invoke(methodName, args); // methodName is null
// after
if (string.IsNullOrWhiteSpace(methodName))
throw new ArgumentException("Hub method name required.", nameof(methodName));
await proxy.Invoke(methodName, args); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(method))
throw new ArgumentException("Server hub method name is required.", nameof(method));
await proxy.Invoke(method, args); Prevention
- Use named constants for hub method names shared with the server.
- Enable nullable reference types so a null method name surfaces at compile time.
- Validate dynamically-built method names before invoking.
When it happens
Trigger: Calling proxy.Invoke(null, ...) or proxy.Invoke<T>(null, onProgress, ...) where the method name argument is null; passing a method name read from config that resolved to null.
Common situations: Method name sourced from a constant that was misnamed/removed, or constructed dynamically and resulting in null.
Related errors
AI-assisted analysis of SignalR/SignalR@693053b89a (2026-08-13).
Data as JSON: /api/errors/fd111396fb8b1be5.
Report an issue: GitHub.