SignalR/SignalR · error · ArgumentNullException
value
Error message
value
What it means
Thrown by the TraceWriter property setter when an attempt is made to assign null. The connection uses TraceWriter to emit diagnostic traces, and a null writer would cause NullReferenceException at trace time, so the setter fails fast at assignment.
Source
Thrown at src/Microsoft.AspNet.SignalR.Client/Connection.cs:314
get
{
return _certCollection;
}
}
public TraceLevels TraceLevel { get; set; }
public TextWriter TraceWriter
{
get
{
return _traceWriter;
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
_traceWriter = value;
}
}
/// <summary>
/// Gets or sets the serializer used by the connection
/// </summary>
public JsonSerializer JsonSerializer
{
get
{
return _jsonSerializer;
}
set
{
if (value == null)View on GitHub (pinned to 693053b89a)
Solutions
- To disable tracing, set TraceLevel = TraceLevels.None rather than nulling the writer.
- Ensure any expression assigned to TraceWriter is non-null (default to Console.Out or a NullTextWriter).
- If using DI, register a non-null TextWriter (e.g. a StringWriter or TextWriter.Null).
Example fix
// before connection.TraceWriter = enableTrace ? logWriter : null; // after connection.TraceWriter = enableTrace ? logWriter : TextWriter.Null; connection.TraceLevel = enableTrace ? TraceLevels.All : TraceLevels.None;
Defensive patterns
Strategy: validation
Validate before calling
if (writer == null) throw new ArgumentNullException(nameof(writer)); // to disable tracing, prefer: connection.TraceLevel = TraceLevels.None; // assign a non-null writer always: connection.TraceWriter = writer ?? TextWriter.Null;
Prevention
- Never assign null to TraceWriter; use TextWriter.Null or set TraceLevel to None.
- Ensure DI registers a non-null TextWriter for the connection.
- Treat a null trace writer as a configuration bug.
When it happens
Trigger: Assigning connection.TraceWriter = null, or assigning an expression that evaluates to null (e.g. a factory that returned null, or a field not yet initialized).
Common situations: Conditionally disabling tracing by setting the writer to null instead of adjusting TraceLevel; DI container failing to resolve a TextWriter and injecting null; a Console.Out capture in a non-console host returning null.
Related errors
- transport
- connection
- key
- Url cannot contain query string directly. Pass query string
- Data cannot be sent because the connection is in the disconn
AI-assisted analysis of SignalR/SignalR@693053b89a (2026-08-13).
Data as JSON: /api/errors/3d7fa43166199ef3.
Report an issue: GitHub.