-
Notifications
You must be signed in to change notification settings - Fork 151
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
Comments
The static API is going away - you need to resolve the mapper from the
service collection.
…On Tue, Jun 25, 2019 at 10:10 PM Jan Paolo Go ***@***.***> wrote:
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!
https://github.com/jbogard/ContosoUniversityCore/blob/07bb0f75a616881b7e513a25f6d0d6b4f0cf664c/src/ContosoUniversityCore/Startup.cs#L44
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
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#35?email_source=notifications&email_token=AAAZQMSK7YSIRAOKXW5EYMTP4LM2VA5CNFSM4H3OBKT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3WJQYA>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAZQMXZDYAVMPWVJSOIJ5TP4LM2VANCNFSM4H3OBKTQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I tried calling
Mapper.AssertConfigurationIsValid
on my project but it threw an exception. Aside fromservices.AddAutoMapper(typeof(Startup))
and aMappingProfile
, what else am I missing? Thanks!ContosoUniversityCore/src/ContosoUniversityCore/Startup.cs
Line 44 in 07bb0f7
Exception details
The text was updated successfully, but these errors were encountered: