3

I am getting an error

Error: CS1729 MapperConfiguration does not contain constructor that takes 1 arguments.

from this code:

var config = new MapperConfiguration(
    options =>
    {
        options.AllowNullDestinationValues = true;
        options.AllowNullCollections = true;
        options.AddProfile(new AutomapperProfiles());
    });

Tried adding a NuGet package for Automapper.

0

1 Answer 1

9

The MapperConfiguration class requires an additional parameter for a logger factory since version 15.0. Check the 15.0 Upgrade Guide - Breaking Changes - MapperConfiguration page for details:

The constructor to MapperConfiguration now requires an ILoggerFactory:

public MapperConfiguration(
   MapperConfigurationExpression configurationExpression, 
   ILoggerFactory loggerFactory)

This parameter is used for diagnostics.

So you have to provide a logger factory as the second argument. Alternatively, you can use an older version of AutoMapper.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much...I was using version 15.0 hence needed two arguments. Now installed 13.0.1, it works as expected. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.