{"record":{"id":"5b4b0520d16ac912","repo":"cefsharp/CefSharp","slug":"other","errorCode":null,"errorMessage":"other","messagePattern":"other","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"CefSharp.Core/RequestContextBuilder.cs","lineNumber":202,"sourceCode":"            {\n                _handler = new RequestContextHandler();\n            }\n\n            _handler.SetProxyOnContextInitialized(scheme, host, port);\n\n            return this;\n        }\n\n        /// <summary>\n        /// Shares storage with other RequestContext\n        /// </summary>\n        /// <param name=\"other\">shares storage with this RequestContext</param>\n        /// <returns>Returns RequestContextBuilder instance</returns>\n        public RequestContextBuilder WithSharedSettings(IRequestContext other)\n        {\n            if (other == null)\n            {\n                throw new ArgumentNullException(\"other\");\n            }\n\n            ThrowExceptionIfCustomSettingSpecified();\n\n            _otherContext = other;\n\n            return this;\n        }\n    }\n}\n","sourceCodeStart":184,"sourceCodeEnd":213,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Core/RequestContextBuilder.cs#L184-L213","documentation":"ArgumentNullException(\"other\") from RequestContextBuilder.WithSharedSettings(IRequestContext other). Sharing storage requires a source context; passing null is meaningless so it fails fast with parameter name 'other' (note: hardcoded string, not nameof). This check runs before ThrowExceptionIfCustomSettingSpecified.","triggerScenarios":"Calling .WithSharedSettings(null) or .WithSharedSettings(unassignedVariable); passing an IRequestContext obtained from a browser that is not yet created; DI resolving IRequestContext to null.","commonSituations":"Trying to share the global context before it exists; factory returning null; overload/dispose race where the source context was just disposed.","solutions":["Ensure the source IRequestContext is created first (e.g. obtain it from an existing ChromiumWebbrowser.GetRequestContext() or Cef.GetGlobalRequestContext()).","Guard the call: only invoke WithSharedSettings when the source is non-null, otherwise fall back to a custom-settings builder.","Register IRequestContext as a non-null singleton in DI.","Enable nullable reference types to catch the null statically."],"exampleFix":"// before\nvar ctx = RequestContext.Configure().WithSharedSettings(parent).Create(); // parent null -> throws\n\n// after\nvar parent = existingBrowser?.GetRequestContext();\nvar builder = RequestContext.Configure();\nif (parent != null) builder = builder.WithSharedSettings(parent);\nelse builder = builder.WithCachePath(@\"C:\\cache\");\nvar ctx = builder.Create();","handlingStrategy":"validation","validationCode":"if (parent == null) throw new InvalidOperationException(\"No RequestContext to share.\");\nvar ctx = RequestContext.Configure().WithSharedSettings(parent).Create();","typeGuard":"public static bool IsShareable(IRequestContext c) => c != null;","tryCatchPattern":"try { return RequestContext.Configure().WithSharedSettings(parent).Create(); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"other\")\n{ /* fall back to custom settings */ return RequestContext.Configure().WithCachePath(cache).Create(); }","preventionTips":["Create/obtain the parent IRequestContext before sharing","Register IRequestContext as a non-null singleton in DI","Enable nullable reference types"],"tags":["csharp","cefsharp","request-context","builder","argument-null","validation"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}