AutoMapper with .Net Core 2.0 not loading profiles from other projects

Created on 29 Aug 2017  Â·  9Comments  Â·  Source: AutoMapper/AutoMapper

I'm using AutoMapper 6.1.1 on a .NET Core 2.0 project.

When adding automapper as dependency

public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddAutoMapper();
        }

The Profiles that I defined in other projects (in the same solution) are not being loaded. Only the Profile defined on the WEB project is loaded.
When I try to user IMapper I get the error missing type map configuration or unsupported mapping

Most helpful comment

solved by myself, posting here just for reference in case anyone else is wondering

services.AddAutoMapper(<assembly>);

something like

services.AddAutoMapper(typeof(a_profile_classe_in_other_assembly).GetTypeInfo().Assembly);

All 9 comments

What version of the AutoMapper extensions package are you using

On Tue, Aug 29, 2017 at 3:43 PM Fernando Fontoura de Almeida <
[email protected]> wrote:

I'm using AutoMapper 6.1.1 on a .NET Core 2.0 project.

When adding automapper as dependency

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddAutoMapper();
}

The Profiles that I defined in other projects (in the same solution) are
not being loaded. Only the Profile defined on the WEB project is loaded.
When I try to user IMapper I get the error missing type map configuration
or unsupported mapping

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/AutoMapper/AutoMapper/issues/2300, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGYMl6DF6wJR-D2YPQkjvbqekwM0ikEks5sdHfkgaJpZM4PGhMq
.

<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.0.1" />

So it's supposed to load everything in the AppDomain, check the AppDomain
assemblies prior to calling AddAutoMapper and make sure they're there.

On Tue, Aug 29, 2017 at 7:37 PM Fernando Fontoura de Almeida <
[email protected]> wrote:

—
You are receiving this because you commented.

Reply to this email directly, view it on GitHub
https://github.com/AutoMapper/AutoMapper/issues/2300#issuecomment-325843714,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGYMtSoCrzNhKCToYLqoFalyKGkwIhOks5sdK68gaJpZM4PGhMq
.

@fontourafernando I'll close this as it's the wrong repository, but feel free to continue the discussion if you still have problems.

@fontourafernando have you managed to solve your problem? I'm upgrading a project from aspnet core 1.x to 2.0 (and automapper from 1.1.2 to 3.0.1) and i have the same issue, with AddAutoMapper not loading profiles from other assemblies

solved by myself, posting here just for reference in case anyone else is wondering

services.AddAutoMapper(<assembly>);

something like

services.AddAutoMapper(typeof(a_profile_classe_in_other_assembly).GetTypeInfo().Assembly);

I had a problem with the latest version 5.0.1. I downgraded to 4.0.1 and it worked. I'm sure it will be fixed soon(assuming something isn't working)

I experienced the same problems and as Bradenb25 suggested downgrading to 4.0.1 solved this. Thanks so much Bradenb25 for posting this, I was already getting really frustrated.

If there is a new issue please open one in the appropriate repository.

Was this page helpful?
0 / 5 - 0 ratings