{"record":{"id":"fe2f1050b7e0267e","repo":"dotnet/wpf","slug":"argumentnullexception-nameof-assemblypath","errorCode":null,"errorMessage":"ArgumentNullException(nameof(assemblyPath))","messagePattern":"ArgumentNullException\\(nameof\\(assemblyPath\\)\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs","lineNumber":186,"sourceCode":"        ///     This allows specifying a path to use when loading the named assembly.\n        /// </summary>\n        /// <param name=\"assemblyName\">\n        /// The short name of the assembly, with no extension or path specified\n        /// </param>\n        /// <param name=\"assemblyPath\">\n        /// The file path of the assembly\n        /// </param>\n        public void SetAssemblyPath(\n            string assemblyName,\n            string assemblyPath)\n        {\n            if( null == assemblyName )\n            {\n                throw new ArgumentNullException(nameof(assemblyName));\n            }\n            if( null == assemblyPath )\n            {\n                throw new ArgumentNullException(nameof(assemblyPath));\n            }\n            if (assemblyPath == string.Empty)\n            {\n                _lineNumber = 0;  // Public API, so we don't know the line number.\n                ThrowException(nameof(SR.ParserBadAssemblyPath));\n            }\n            if (assemblyName == string.Empty)\n            {\n                _lineNumber = 0;  // Public API, so we don't know the line number.\n                ThrowException(nameof(SR.ParserBadAssemblyName));\n            }\n\n            string asmName = assemblyName.ToUpper(CultureInfo.InvariantCulture);\n            lock (_assemblyPathTable)\n            {\n                _assemblyPathTable[asmName] = assemblyPath;\n            }\n","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs#L168-L204","documentation":"XamlTypeMapper.SetAssemblyPath throws ArgumentNullException when assemblyPath is null. The path is used to locate and load the assembly during XAML parsing; a null path would break resolution later, so the API rejects it up front. Note it also rejects the empty string as a separate error.","triggerScenarios":"Calling SetAssemblyPath(assemblyName, null) — often when the path comes from a settings file, registry value, or probe that returned null because the assembly wasn't found.","commonSituations":"Custom designer/parse hosts mapping assemblies to disk paths; deployment changes where an assembly's registered path entry is missing; tests passing null placeholders.","solutions":["Pass the full path to the assembly file as the second argument","Ensure the assembly actually exists on disk and its path was resolved before calling","Use Assembly.Location (checked for non-empty) to obtain the path"],"exampleFix":"// before\nstring path = settings.GetPath(assemblyName); // null when not configured\nmapper.SetAssemblyPath(assemblyName, path);\n// after\nstring path = settings.GetPath(assemblyName);\nif (path == null) path = Assembly.ReflectionOnlyLoad(assemblyName).Location;\nmapper.SetAssemblyPath(assemblyName, path);","handlingStrategy":"validation","validationCode":"if (assemblyPath == null || !File.Exists(assemblyPath))\n    throw new FileNotFoundException(\"Assembly path missing\", assemblyPath);\nmapper.SetAssemblyPath(assemblyName, assemblyPath);","typeGuard":"bool IsValidAssemblyPath(string path) => !string.IsNullOrEmpty(path) && File.Exists(path);","tryCatchPattern":"try\n{\n    mapper.SetAssemblyPath(assemblyName, assemblyPath);\n}\ncatch (ArgumentNullException ex) when (ex.ParamName == \"assemblyPath\")\n{\n    log.LogError(ex, \"No disk path registered for {Assembly}\", assemblyName);\n}","preventionTips":["Verify the assembly exists on disk before registering its path","Resolve paths with Path.GetFullPath and check File.Exists","Handle missing config entries for assembly locations explicitly"],"tags":["wpf","xaml","argument-null","path"],"backgroundTag":"null-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}