{"record":{"id":"cd70ac6b7c63de31","repo":"LuckyPennySoftware/AutoMapper","slug":"the-type-typemap-destinationtype-name-does-not-h","errorCode":null,"errorMessage":"The type {typeMap.DestinationType.Name} does not have a constructor.\\n{typeMap.DestinationType.FullName}","messagePattern":"The type (.+?) does not have a constructor\\.\\\\n(.+?)","errorType":"validation","errorClass":"AutoMapperConfigurationException","httpStatus":null,"severity":"error","filePath":"src/AutoMapper/Configuration/CtorParamConfigurationExpression.cs","lineNumber":61,"sourceCode":"    public void MapFrom<TMember>(Expression<Func<TSource, TMember>> sourceMember) =>\n        _ctorParamActions.Add(cpm => cpm.MapFrom(sourceMember));\n    public void MapFrom<TMember>(Func<TSource, ResolutionContext, TMember> resolver)\n    {\n        Expression<Func<TSource, TDestination, TMember, ResolutionContext, TMember>> resolverExpression = (src, dest, destMember, ctxt) => resolver(src, ctxt);\n        _ctorParamActions.Add(cpm => cpm.SetResolver(new FuncResolver(resolverExpression)));\n    }\n    public void MapFrom(string sourceMembersPath)\n    {\n        var sourceMembers = ReflectionHelper.GetMemberPath(SourceType, sourceMembersPath);\n        _ctorParamActions.Add(cpm => cpm.MapFrom(sourceMembersPath, sourceMembers));\n    }\n    public void ExplicitExpansion(bool value) => _ctorParamActions.Add(cpm => cpm.ExplicitExpansion = value);\n    public void Configure(TypeMap typeMap)\n    {\n        var ctorMap = typeMap.ConstructorMap;\n        if (ctorMap == null)\n        {\n            throw new AutoMapperConfigurationException($\"The type {typeMap.DestinationType.Name} does not have a constructor.\\n{typeMap.DestinationType.FullName}\");\n        }\n        var parameter = ctorMap[CtorParamName];\n        if (parameter == null)\n        {\n            throw new AutoMapperConfigurationException($\"{typeMap.DestinationType.Name} does not have a matching constructor with a parameter named '{CtorParamName}'.\\n{typeMap.DestinationType.FullName}.{typeMap.CheckRecord()}\");\n        }\n        foreach (var action in _ctorParamActions)\n        {\n            action(parameter);\n        }\n    }\n}","sourceCodeStart":43,"sourceCodeEnd":73,"githubUrl":"https://github.com/LuckyPennySoftware/AutoMapper/blob/dfa6dd587c5854b4beee5934beb39ba6e9569b84/src/AutoMapper/Configuration/CtorParamConfigurationExpression.cs#L43-L73","documentation":"Thrown when ForCtorParam is configured for a destination type whose ConstructorMap is null, meaning AutoMapper found no constructor it can use for constructor mapping. This occurs when the destination type has no accessible parameterized constructor that AutoMapper can match against source members, or when constructor mapping was bypassed. The Configure method checks typeMap.ConstructorMap and throws before attempting to resolve the parameter.","triggerScenarios":"Calling .ForCtorParam(\"id\", opt => ...) on a CreateMap whose destination type has no public constructor (only a parameterless one, or none), or whose destination is an interface or abstract class. Also happens when ConstructUsing overrides the constructor so ConstructorMap is never populated.","commonSituations":"Destination type is an interface or abstract class with no concrete constructor; destination type only has a private or internal constructor; you used ConstructUsing to supply a custom factory and also tried ForCtorParam.","solutions":["Ensure the destination type has at least one public constructor with parameters AutoMapper can resolve.","Remove the ForCtorParam call if you are already using ConstructUsing to create the destination instance.","If the destination is an interface, map to a concrete implementation type or use AsProxy.","Make the constructor public if it was private/internal."],"exampleFix":"// before — no public constructor on Dest\npublic class Dest { private Dest() { } }\nCreateMap<Source, Dest>().ForCtorParam(\"name\", opt => opt.MapFrom(\"Name\"));\n\n// after — add a public constructor\npublic class Dest { public Dest(string name) { Name = name; } public string Name { get; set; } }","handlingStrategy":"validation","validationCode":"// Check the destination type has a public constructor before using ForCtorParam\nvar ctors = typeof(TDestination).GetConstructors(BindingFlags.Public | BindingFlags.Instance);\nif (ctors.Length == 0)\n    throw new InvalidOperationException($\"{typeof(TDestination).Name} has no public constructor; cannot use ForCtorParam.\");\n// Safe to call ForCtorParam now","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure destination types used with ForCtorParam always have at least one public parameterized constructor.","Do not mix ForCtorParam with ConstructUsing — the latter bypasses constructor mapping.","Write a unit test that creates the mapper and calls AssertConfigurationIsValid to catch this at test time."],"tags":["configuration","constructor","ctor-param","mapping"],"backgroundTag":null,"analyzedSha":"dfa6dd587c5854b4beee5934beb39ba6e9569b84","analyzedAt":"2026-08-13T19:56:33.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}