Error "Non-static method requires a target." on nullable properties

11 views
Skip to first unread message

wayne....@gmail.com

unread,
Apr 10, 2017, 11:15:14 AM4/10/17
to AutoMapper-users
Hello community! Has anyone else run in to an error when using 6.0.2 when trying to automap to nullable properties? For example, I have an incoming DTO that has a property:

public double? DistanceInKm { get; set; }

That is being mapped to an object with an identical property. In 5.2.0, this worked with no issue, after upgrading to 6.0.2 it throws the following error:

<Exception>
Error mapping types.
Mapping types:
Provider -> ProviderListViewModel
Portals.DataContracts.Public.Dtos.Responses.Providers.Provider -> BCBSLA_Proto.ViewModels.Providers.ProviderListViewModel

Type Map configuration:
Provider -> ProviderListViewModel
Portals.DataContracts.Public.Dtos.Responses.Providers.Provider -> BCBSLA_Proto.ViewModels.Providers.ProviderListViewModel

Property:
DistanceInKm

<Inner Exception>
Non-static method requires a target.

   at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.InvokeWorker(Object[] args)
   at System.Linq.Expressions.Interpreter.MethodInfoCallInstruction.Run(InterpretedFrame frame)
   at System.Linq.Expressions.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

Switching back to 5.2.0 makes this work again as expected. I first noticed this with a nullable integer property in a different object, but thought it was my code and created a manual mapping but when it happened to another property, figured it had to be something AutoMapper. Does anyone have any ideas as to what's going on? Thanks in advance!

Wayne Dupree

Jimmy Bogard

unread,
Apr 10, 2017, 7:58:55 PM4/10/17
to automapper-users
Can you open a GH issue?

--
You received this message because you are subscribed to the Google Groups "AutoMapper-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wayne Dupree

unread,
Apr 10, 2017, 9:32:52 PM4/10/17
to AutoMapper-users
Will do, thanks!
To unsubscribe from this group and stop receiving emails from it, send an email to automapper-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages