question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NuGet ABP 4.9

I found the ABP 4.9 in NuGet, https://www.nuget.org/packages/Abp

AbpAutoMapperModule

In AbpAutoMapperModule, register the Mapper.Instance for IMapper.

if (Configuration.Modules.AbpAutoMapper().UseStaticMapper)
{
    //We should prevent duplicate mapping in an application, since Mapper is static.
    if (!_createdMappingsBefore)
    {
        Mapper.Initialize(configurer);
        _createdMappingsBefore = true;
    }

    IocManager.IocContainer.Register(
        Component.For<IConfigurationProvider>().Instance(Mapper.Configuration).LifestyleSingleton()
    );
    IocManager.IocContainer.Register(
        Component.For<IMapper>().Instance(Mapper.Instance).LifestyleSingleton()
    );
}
else
{
    var config = new MapperConfiguration(configurer);
    IocManager.IocContainer.Register(
        Component.For<IConfigurationProvider>().Instance(config).LifestyleSingleton()
    );
    IocManager.IocContainer.Register(
        Component.For<IMapper>().Instance(config.CreateMapper()).LifestyleSingleton()
    );
}

and then, I use Mapper.Instance will throw InvalidOperationException:

Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to us…

but get IMapper by IcC, like:

public override void PostInitialize()
{
    var b = IocManager.Resolve<IMapper>();

    var a  = Mapper.Instance;
}

the b is a valid entity. b regist by Mapper.Instance, isn’t it?

Why?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jerviscuicommented, Sep 5, 2019

OK, I find the reason. Resharper Lied to me, I will use AbpEmulateAutoMapper.Mapper.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Abp 4.9.0
Version Downloads Last updated 8.3.1 224 a day ago 8.3.0 62 a day ago 8.2.0 21,951 3 months ago
Read more >
Abp.EntityFrameworkCore 4.9.0
Abp.EntityFrameworkCore 4.9.0. The ID prefix of this package has been reserved for one of the owners of this Prefix Reserved .NET Standard 2.0....
Read more >
Abp.ZeroCore 4.9.0
Version Downloads Last updated 8.2.0 3,941 2 months ago 8.1.0 19,934 4 months ago 8.0.0 28,197 7 months ago
Read more >
Abp.AspNetCore.OData 4.9.0
Abp.AspNetCore.OData 4.9.0 ·.NET CLI · Package Manager · PackageReference · Paket CLI · Script & Interactive · Cake.
Read more >
Abp.Web.Common 4.9.0
Version Downloads Last updated 8.2.0 695 12 days ago 8.1.0 11,613 3 months ago 8.0.0 23,629 6 months ago
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found