-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExpressMapper crashes when Mapper.Compile() is called: Default constructor not found #144
Comments
Are you sure that you don't have constructor for a |
that is a class generated by Entity Framework, hence the partial keyword. but No, it cab be instantiated on its own and that's how I have used it in the code. |
from the documentation I tried this so that it would not have to create the object itself but it still gives the same error.
|
Looks like my issue already described, but I want confirm that issue exists. I have a sample which works perfectly And have a PagedListConverter used in previous screenshot Now I want to use generic method (in generic class) for selecting paged list collection (I'm using PagedList ) But the error occurs like mentioned in title of the issue I don't understand why it happens because in first screenshot code this mapping works perfectly. Furthermore, all used Models and ViewModels have default constructor. Concerning PagedList, a specilficallly for that is used PagedListResolver (it works great in second screenshot). I'm trying to use your mapper instead if my favorite (for this time) AutoMapper. If I can resolve this issue, your mapper become my favorite (for many reasons). Please help! |
I have the following classes for which I'm using the ExpressMapper.
However I always get this exception. It can be noted that the above two classes can be instaintiated directly and require no special initialization for instance:
Here is the stacktrack from ExpressMapper:
Error Could not initialize application object properly. See the stacktrace for more detail ExpressMapper.ExpressmapperException: Error error occurred trying to compile mapping for: source Models.EquipmentRequirementEditModel, destination Entities.Requirement. See the inner exception for details. ---> System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at ExpressMapper.MappingServiceBase.GetMapExpressions(Type src, Type dest) in C:\Source\ExpressMapper\Expressmapper.Shared\MappingServiceBase.cs:line 58
at ExpressMapper.SourceMappingService.MapProperty(Type srcType, Type destType, Expression srcExpression, Expression destExpression, Boolean newDest) in C:\Source\ExpressMapper\Expressmapper.Shared\SourceMappingService.cs:line 78
at ExpressMapper.MappingServiceBase.GetDifferentTypeMemberMappingExpression(Expression srcExpression, Expression destExpression, Boolean newDest) in C:\Source\ExpressMapper\Expressmapper.Shared\MappingServiceBase.cs:line 313
at ExpressMapper.MappingServiceBase.GetMemberMappingExpression(Expression left, Expression right, Boolean newDest) in C:\Source\ExpressMapper\Expressmapper.Shared\MappingServiceBase.cs:line 186
at ExpressMapper.TypeMapperBase
2.MapMember(MemberExpression left, Expression right) in C:\Source\ExpressMapper\Expressmapper.Shared\TypeMapperBase.cs:line 249 at ExpressMapper.TypeMapperBase
2.AutoMapProperty(MemberInfo propertyGet, MemberInfo propertySet) in C:\Source\ExpressMapper\Expressmapper.Shared\TypeMapperBase.cs:line 206at ExpressMapper.TypeMapperBase
2.ProcessAutoProperties() in C:\Source\ExpressMapper\Expressmapper.Shared\TypeMapperBase.cs:line 326 at ExpressMapper.SourceTypeMapper
2.CompileInternal() in C:\Source\ExpressMapper\Expressmapper.Shared\SourceTypeMapper.cs:line 40at ExpressMapper.TypeMapperBase`2.Compile(CompilationTypes compilationType, Boolean forceByDemand) in C:\Source\ExpressMapper\Expressmapper.Shared\TypeMapperBase.cs:line 119
--- End of inner exception stack trace ---
The text was updated successfully, but these errors were encountered: