question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AutoMapper 4 targeting wrong constructor on instantiation

See original GitHub issue

After updating to AutoMapper 4, I am receiving an error in a situation that used to work. I have 2 different objects that I am trying to create a mapping for (ImportedContact -> Contact). The destination object (Contact) has 2 constructors, one without parameters and another with 2 reference type parameters (SerializationInfo, StreamingContext). When I try calling Mapper.Map to instantiate a new instance of the destination object (Contact) it is calling the constructor that takes 2 parameters. AutoMapper 3 was using the parameter-less constructor. This causes the following error:

"Missing type map configuration or unsupported mapping.

Mapping types:
ImportedContact -> SerializationInfo
SharePointDirectory.Jobs.ImportedContact -> System.Runtime.Serialization.SerializationInfo

Destination path:
Contact

Source value:
SharePointDirectory.Jobs.ImportedContact"

Here is a link to some files that I have uploaded to Gist that can be put into a Console app and when ran will demonstrate the issue. https://gist.github.com/ristogod/60ac506272bdd519485a

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jbogardcommented, Aug 28, 2015

@TylerCarlson1 eleventy.

0reactions
lock[bot]commented, May 8, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - AutoMapper using the wrong constructor
Takes first constructor which parameters match source properties (without any check for null value). In your case it is constructor with two ...
Read more >
Automapper custom resolver throws null exception in ...
Hi,. We are using AutoMapper in our Commerce site. While mapping from the custom model to an EPiServer Model(VariationContent) throws a below error....
Read more >
AutoMapper Documentation
A convention-based object-object mapper. AutoMapper uses a fluent configuration API to define an object-object mapping strategy.
Read more >
Reflection and C# optional constructor arguments
(AutoMapper allows constructors to be used for creating new instances, using the "ConvertUsing" method, but it doesn't do its magic with ...
Read more >
The reasons behind why I don't use AutoMapper.
Some people say that AutoMapper is perfectly fine for simple projects, but believe me - there is no such thing as simple project....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found