{"record":{"id":"5591edc486c51413","repo":"LuckyPennySoftware/AutoMapper","slug":"cannot-find-any-profiles-with-the-name-profilena","errorCode":null,"errorMessage":"Cannot find any profiles with the name '{profileName}'.","messagePattern":"Cannot find any profiles with the name '(.+?)'\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/AutoMapper/Configuration/MapperConfiguration.cs","lineNumber":521,"sourceCode":"    IObjectMapper IGlobalConfiguration.FindMapper(TypePair types) => FindMapper(types);\n    IObjectMapper FindMapper(TypePair types)\n    {\n        foreach (var mapper in _mappers)\n        {\n            if (mapper.IsMatch(types))\n            {\n                return mapper;\n            }\n        }\n        return null;\n    }\n    void IGlobalConfiguration.RegisterTypeMap(TypeMap typeMap) => _configuredMaps[typeMap.Types] = typeMap;\n    void IGlobalConfiguration.AssertConfigurationIsValid(TypeMap typeMap) => Validator().AssertConfigurationIsValid([typeMap]);\n    void IGlobalConfiguration.AssertConfigurationIsValid(string profileName)\n    {\n        if (Array.TrueForAll(Profiles, x => x.Name != profileName))\n        {\n            throw new ArgumentOutOfRangeException(nameof(profileName), $\"Cannot find any profiles with the name '{profileName}'.\");\n        }\n        Validator().AssertConfigurationIsValid(_configuredMaps.Values.Where(typeMap => typeMap.Profile.Name == profileName).ToArray());\n    }\n    void IGlobalConfiguration.AssertConfigurationIsValid<TProfile>() => this.Internal().AssertConfigurationIsValid(typeof(TProfile).FullName);\n    void IGlobalConfiguration.RegisterAsMap(TypeMapConfiguration typeMapConfiguration) =>\n        _resolvedMaps[typeMapConfiguration.Types] = GetIncludedTypeMap(new(typeMapConfiguration.SourceType, typeMapConfiguration.DestinationTypeOverride));\n\n    string IGlobalConfiguration.LicenseKey => _configurationExpression.LicenseKey;\n}\nstruct LazyValue<T>(Func<T> factory) where T : class\n{\n    readonly Func<T> _factory = factory;\n    T _value = null;\n    public T Value => LazyInitializer.EnsureInitialized(ref _value, _factory);\n}","sourceCodeStart":503,"sourceCodeEnd":536,"githubUrl":"https://github.com/LuckyPennySoftware/AutoMapper/blob/dfa6dd587c5854b4beee5934beb39ba6e9569b84/src/AutoMapper/Configuration/MapperConfiguration.cs#L503-L536","documentation":"Thrown by AssertConfigurationIsValid(string profileName) when no registered Profile has a Name property matching the supplied argument. The method uses Array.TrueForAll to check that no profile name matches, then throws ArgumentOutOfRangeException. The default Profile.Name is the fully-qualified type name of the profile class.","triggerScenarios":"Calling mapper.ConfigurationProvider.AssertConfigurationIsValid(\"MyProfile\") where the string does not match any Profile.Name. Common mistake: passing the short class name when Profile.Name defaults to the fully qualified name.","commonSituations":"Using the class name \"OrderProfile\" instead of the full name \"MyApp.Profiles.OrderProfile\"; typo in the profile name string; profile was not registered in the configuration.","solutions":["Use the generic overload AssertConfigurationIsValid<OrderProfile>() which resolves the name automatically via typeof(TProfile).FullName.","Inspect Profile.Name — it defaults to typeof(T).FullName unless overridden in the constructor.","If you set a custom Name in the Profile constructor (Profile.Name = \"Short\"), use that exact string.","Verify the profile is actually registered via AddProfile<T>() or AddProfiles()."],"exampleFix":"// before — name mismatch (Profile.Name defaults to fully qualified name)\nmapper.ConfigurationProvider.AssertConfigurationIsValid(\"OrderProfile\");\n\n// after — use the generic overload\ncfg.AssertConfigurationIsValid<OrderProfile>();\n// or set a short name and use it\npublic class OrderProfile : Profile { public OrderProfile() { Profile.Name = \"Orders\"; } }\nmapper.ConfigurationProvider.AssertConfigurationIsValid(\"Orders\");","handlingStrategy":"validation","validationCode":"// Validate the profile name exists before calling AssertConfigurationIsValid\nvar profileName = \"MyProfile\";\nif (!config.Profiles.Any(p => p.Name == profileName))\n    throw new InvalidOperationException($\"Profile '{profileName}' not found. Available: {string.Join(\", \", config.Profiles.Select(p => p.Name))}\");\n// Or simply use the generic overload to avoid string-based lookup:\n// config.AssertConfigurationIsValid<MyProfile>();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the generic overload AssertConfigurationIsValid<TProfile>() to avoid string-based name lookups.","If using string names, set Profile.Name explicitly in the constructor for stability.","Remember the default Profile.Name is the fully qualified type name.","Log available profile names during startup for easy debugging."],"tags":["validation","profiles","configuration"],"backgroundTag":null,"analyzedSha":"dfa6dd587c5854b4beee5934beb39ba6e9569b84","analyzedAt":"2026-08-13T19:56:33.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}