{"record":{"id":"3d7fa43166199ef3","repo":"SignalR/SignalR","slug":"value","errorCode":null,"errorMessage":"value","messagePattern":"value","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.AspNet.SignalR.Client/Connection.cs","lineNumber":314,"sourceCode":"            get\n            {\n                return _certCollection;\n            }\n        }\n\n        public TraceLevels TraceLevel { get; set; }\n\n        public TextWriter TraceWriter\n        {\n            get\n            {\n                return _traceWriter;\n            }\n            set\n            {\n                if (value == null)\n                {\n                    throw new ArgumentNullException(\"value\");\n                }\n\n                _traceWriter = value;\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets the serializer used by the connection\n        /// </summary>\n        public JsonSerializer JsonSerializer\n        {\n            get\n            {\n                return _jsonSerializer;\n            }\n            set\n            {\n                if (value == null)","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/SignalR/SignalR/blob/693053b89a9e1f5ce819e3233ed159a6409de22b/src/Microsoft.AspNet.SignalR.Client/Connection.cs#L296-L332","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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)."],"exampleFix":"// before\nconnection.TraceWriter = enableTrace ? logWriter : null;\n\n// after\nconnection.TraceWriter = enableTrace ? logWriter : TextWriter.Null;\nconnection.TraceLevel = enableTrace ? TraceLevels.All : TraceLevels.None;","handlingStrategy":"validation","validationCode":"if (writer == null) throw new ArgumentNullException(nameof(writer));\n// to disable tracing, prefer:\nconnection.TraceLevel = TraceLevels.None;\n// assign a non-null writer always:\nconnection.TraceWriter = writer ?? TextWriter.Null;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["signalr","client","tracing","null-check","validation"],"backgroundTag":null,"analyzedSha":"693053b89a9e1f5ce819e3233ed159a6409de22b","analyzedAt":"2026-08-13T22:23:59.793Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}