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

Version 6.2.0 - System.InvalidOperationException: 'Mapper already initialized. You must call Initialize once per application domain/process.' #2405

Closed
byrneciaran opened this Issue Nov 15, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@byrneciaran

byrneciaran commented Nov 15, 2017

I'm using AutoMapper with Xamarin Android. It's no longer working in 6.2 and I'm receiving the exception:

System.InvalidOperationException: 'Mapper already initialised. You must call initialised once per application domain/process.'

I was doing my initialisation in the OnCreate method of my Activity, but if the app is backgrounded and then resumed, the method gets called again and the the exception occurs. I don't know where else I can call it, due to the way Android is architected. I tried experimenting with singletons with no joy.

Mapping configuration

  Mapper.Initialize(cfg =>
            {
                cfg.CreateMap<Field, FormField>();
                cfg.CreateMap<Item, FormFieldItem>();
                cfg.CreateMap<Metadata, FormMetadata>();
                cfg.CreateMap<FormField, Field>();
                cfg.CreateMap<FormFieldItem, Item>();
                cfg.CreateMap<FormMetadata, Metadata>();
            });

Version: x.y.z

6.2.0

Expected behavior

This worked in versions before 6.1.0

Actual behavior

System.InvalidOperationException: 'Mapper already initialized. You must call Initialize once per application domain/process.'

Steps to reproduce

@lbargaoanu

This comment has been minimized.

Show comment
Hide comment
@lbargaoanu

lbargaoanu Nov 15, 2017

Member

Duplicate of #2399. You might want to watch #2404, but it should be easy to fix without it.

Member

lbargaoanu commented Nov 15, 2017

Duplicate of #2399. You might want to watch #2404, but it should be easy to fix without it.

@lbargaoanu lbargaoanu closed this Nov 15, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment