Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

c# - AutoMapper DI Problems with netcore 5.0

Target FrameWork: Net Core 5.0 IDE: Visual Studio 2019

Project Type: WebAPI

use DI version: autofac 6.1.0 use Automapper version: 10.1.1

Error Description: I'm trying to learn ApplicationPart(https://docs.microsoft.com/zh-cn/aspnet/core/mvc/advanced/app-parts?view=aspnetcore-5.0) , and when i load the applicationpart class library with assembly

        var mvcBuilder = services.AddMvc();

        var assemblies = AssemblyHelper.GetAssemblies(AppSetting.ModuleDir);
        foreach (var assembly in assemblies)
        {
            if (AppSetting.LoadModules == null || !AppSetting.LoadModules.Contains<string>(assembly.GetName().Name))
            {
                continue;
            }
            mvcBuilder.SetCompatibilityVersion(CompatibilityVersion.Version_3_0).AddApplicationPart(assembly);
        }

and then , i register type with autofac or any DI tools

builder.RegisterModule(new AutoMapperModule(AppDomain.CurrentDomain.GetAssemblies()));

or

services.AddAutoMapper(typeof(MappingProfile));

enter image description here

iget this eroor enter image description here

but if load applicaitonpart without assembly,It's a direct reference to the project i can get success run ....

enter image description here

enter image description here

please , tell me why ? i get the trouble a long time

question from:https://stackoverflow.com/questions/65882847/automapper-di-problems-with-netcore-5-0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...