Skip to content
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

Mapper.AssertConfigurationIsValid throws Mapper not initialized #35

Open
gojanpaolo opened this issue Jun 26, 2019 · 1 comment
Open

Comments

@gojanpaolo
Copy link

Hi. I tried calling Mapper.AssertConfigurationIsValid on my project but it threw an exception. Aside from services.AddAutoMapper(typeof(Startup)) and a MappingProfile, what else am I missing? Thanks!

Mapper.AssertConfigurationIsValid();

Exception details

System.InvalidOperationException
  HResult=0x80131509
  Message=Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.
  Source=AutoMapper
  StackTrace:
   at AutoMapper.Mapper.get_Configuration()
   at AutoMapper.Mapper.AssertConfigurationIsValid()
   at Gldd.Api.Startup.ConfigureServices(IServiceCollection services) in C:\git\cutter-stripcharts-prototype\src\Gldd.Api\Startup.cs:line 36
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
   at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.Internal.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Gldd.Api.Program.Main(String[] args) in C:\git\cutter-stripcharts-prototype\src\Gldd.Api\Program.cs:line 10
@jbogard
Copy link
Owner

jbogard commented Jul 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants