{"record":{"id":"2bc398fb03ae1627","repo":"LuckyPennySoftware/AutoMapper","slug":"cannot-find-member-name-of-type-type","errorCode":null,"errorMessage":"Cannot find member {name} of type {type}.","messagePattern":"Cannot find member (.+?) of type (.+?)\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/AutoMapper/Internal/TypeExtensions.cs","lineNumber":52,"sourceCode":"        var currentType = type;\n        while ((currentType = currentType.BaseType) != null)\n        {\n            yield return currentType;\n        }\n        foreach (var interfaceType in type.GetInterfaces())\n        {\n            yield return interfaceType;\n        }\n    }\n\n    public static PropertyInfo GetInheritedProperty(this Type type, string name) => type.GetProperty(name, InstanceFlags) ?? type.GetBaseProperty(name);\n    static PropertyInfo GetBaseProperty(this Type type, string name) =>\n        type.BaseClassesAndInterfaces().Select(t => t.GetProperty(name, InstanceFlags)).FirstOrDefault(p => p != null);\n    public static FieldInfo GetInheritedField(this Type type, string name) => type.GetField(name, InstanceFlags) ?? type.GetBaseField(name);\n    static FieldInfo GetBaseField(this Type type, string name) =>\n        type.BaseClassesAndInterfaces().Select(t => t.GetField(name, InstanceFlags)).FirstOrDefault(f => f != null);\n    public static MethodInfo GetInheritedMethod(this Type type, string name) => type.GetInstanceMethod(name) ?? type.GetBaseMethod(name) ??\n        throw new ArgumentOutOfRangeException(nameof(name), $\"Cannot find member {name} of type {type}.\");\n    static MethodInfo GetBaseMethod(this Type type, string name) =>\n        type.BaseClassesAndInterfaces().Select(t => t.GetInstanceMethod(name)).FirstOrDefault(m => m != null);\n\n    public static MemberInfo GetFieldOrProperty(this Type type, string name)\n        => type.GetInheritedProperty(name) ?? (MemberInfo)type.GetInheritedField(name) ?? throw new ArgumentOutOfRangeException(nameof(name), $\"Cannot find member {name} of type {type}.\");\n\n    public static bool IsNullableType(this Type type) => type.IsGenericType(typeof(Nullable<>));\n\n    public static Type GetICollectionType(this Type type) => type.GetGenericInterface(typeof(ICollection<>));\n\n    public static bool IsCollection(this Type type) => type != typeof(string) && typeof(IEnumerable).IsAssignableFrom(type);\n\n    public static bool IsListType(this Type type) => typeof(IList).IsAssignableFrom(type);\n\n    public static bool IsGenericType(this Type type, Type genericType) => type.IsGenericType && type.GetGenericTypeDefinition() == genericType;\n\n    public static Type GetIEnumerableType(this Type type) => type.GetGenericInterface(typeof(IEnumerable<>));\n","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/LuckyPennySoftware/AutoMapper/blob/dfa6dd587c5854b4beee5934beb39ba6e9569b84/src/AutoMapper/Internal/TypeExtensions.cs#L34-L70","documentation":"Thrown by GetInheritedMethod when no instance method with the given name can be found on the type, its base classes, or its implemented interfaces. The method searches the type first, then walks BaseClassesAndInterfaces. This is called internally by reflection helpers such as GetMemberPath when resolving a dotted member path where a segment is neither a property nor a field, so it falls through to a method lookup.","triggerScenarios":"Calling MapFrom(\"dotted.path\") where a path segment is not a property or field and also not a method on the source type; or an internal lookup for a method name that was renamed or removed.","commonSituations":"Misspelled member name in a string-based MapFrom path; renamed a method after writing the mapping; dotted path referencing a member that exists on a different overload or is static rather than instance.","solutions":["Verify each segment in the dotted member path string exists as a property, field, or instance method on the source type.","Prefer lambda-based MapFrom(s => s.Prop.SubProp) for compile-time safety and IntelliSense.","Check for typos and case-sensitivity in the member path string."],"exampleFix":"// before — misspelled member in string path\nCreateMap<Source, Dest>().ForMember(\"Value\", opt => opt.MapFrom(\"CalcualtedValue\"));\n\n// after — correct name or use lambda\nCreateMap<Source, Dest>().ForMember(\"Value\", opt => opt.MapFrom(s => s.CalculatedValue));","handlingStrategy":"validation","validationCode":"// Validate that a method exists on the source type before using it in a dotted path\nvar methodName = \"GetData\";\nif (typeof(TSource).GetInstanceMethod(methodName) == null &&\n    !typeof(TSource).BaseClassesAndInterfaces().Any(t => t.GetInstanceMethod(methodName) != null))\n    throw new MissingMethodException(typeof(TSource).Name, methodName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer lambda-based MapFrom over string-based dotted paths for compile-time safety.","When using string paths, verify each segment exists as a property, field, or instance method.","Check for typos and case-sensitivity in member path strings."],"tags":["reflection","method-lookup","member-path","string-based-mapping"],"backgroundTag":null,"analyzedSha":"dfa6dd587c5854b4beee5934beb39ba6e9569b84","analyzedAt":"2026-08-13T19:56:33.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}