{"record":{"id":"f4f64ee370047f1e","repo":"dotnet/wpf","slug":"sr-serializerproviderdisplaynamenull","errorCode":null,"errorMessage":"SR.SerializerProviderDisplayNameNull","messagePattern":"SR\\.SerializerProviderDisplayNameNull","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerDescriptor.cs","lineNumber":66,"sourceCode":"\n        /// <summary>\n        /// Creates a SerializerDescriptor. The interface must be defined in the calling assembly\n        /// The WinFX version, and assembly name, and version are initialized by reflecting on the calling assembly\n        /// </summary>\n        /// <remarks>\n        ///     Create a SerializerDescriptor from a ISerializerFactory instance\n        ///\n        ///     This method currently requires full trust to run.\n        /// </remarks>\n        public static SerializerDescriptor CreateFromFactoryInstance(\n            ISerializerFactory  factoryInstance\n            )\n        {\n\n            ArgumentNullException.ThrowIfNull(factoryInstance);\n            if (factoryInstance.DisplayName == null)\n            {\n                throw new ArgumentException(SR.SerializerProviderDisplayNameNull);\n            }\n            if (factoryInstance.ManufacturerName == null)\n            {\n                throw new ArgumentException(SR.SerializerProviderManufacturerNameNull);\n            }\n            if (factoryInstance.ManufacturerWebsite == null)\n            {\n                throw new ArgumentException(SR.SerializerProviderManufacturerWebsiteNull);\n            }\n            if (factoryInstance.DefaultFileExtension == null)\n            {\n                throw new ArgumentException(SR.SerializerProviderDefaultFileExtensionNull);\n            }\n\n            SerializerDescriptor sd = new SerializerDescriptor\n            {\n                _displayName = factoryInstance.DisplayName,\n                _manufacturerName = factoryInstance.ManufacturerName,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Serialization/SerializerDescriptor.cs#L48-L84","documentation":"SerializerDescriptor.CreateFromFactoryInstance validates every property of the supplied ISerializerFactory and throws ArgumentException (SR.SerializerProviderDisplayNameNull) when factoryInstance.DisplayName is null. A serializer descriptor cannot be created or registered without a display name, since it forms part of the registry key and the serializer metadata exposed to users.","triggerScenarios":"Calling SerializerDescriptor.CreateFromFactoryInstance or SerializerProvider.RegisterSerializer with an ISerializerFactory whose DisplayName property returns null.","commonSituations":"Implementing a custom ISerializerFactory and forgetting to set DisplayName in the class or its constructor; a factory whose DisplayName getter computes a value that resolves to null (e.g. from missing resources or config).","solutions":["Set DisplayName in the custom ISerializerFactory implementation to a non-null string","Validate the factory's properties before calling CreateFromFactoryInstance/RegisterSerializer","Throw ArgumentNullException from the factory constructor if a required name parameter is null so the mistake surfaces early"],"exampleFix":"// before\nclass MySerializerFactory : ISerializerFactory { public string DisplayName => null; ... }\n// after\nclass MySerializerFactory : ISerializerFactory { public string DisplayName => \"My Serializer\"; ... }","handlingStrategy":"validation","validationCode":"if (factory == null) throw new ArgumentNullException(nameof(factory));\nif (factory.DisplayName == null) throw new InvalidOperationException(\"Serializer DisplayName must be set before registration\");","typeGuard":"bool HasDisplayName(ISerializerFactory f) => !string.IsNullOrEmpty(f.DisplayName);","tryCatchPattern":"try { SerializerProvider.RegisterSerializer(descriptor); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"DisplayName\")) { /* fix factory implementation */ }","preventionTips":["Initialize all ISerializerFactory properties in the constructor","Unit-test custom factories against SerializerDescriptor.CreateFromFactoryInstance before shipping","Use string constants or resource-backed non-null defaults for metadata"],"tags":["wpf","serializer","null-argument","argumentexception"],"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"}