小编Sai*_*ito的帖子

使用UsingConstructor注册RegisterAssemblyTypes

我想注册具有多个构造函数的程序集类型自动装配选择错误的构造函数并希望像在RegisterType中一样指定它

builder.RegisterType(typeof(IController))
    .UsingConstructor(typeof(IUnitOfWork));
Run Code Online (Sandbox Code Playgroud)

但是当我这样做的时候

builder.RegisterAssemblyTypes(typeof(IController).Assembly)
    .UsingConstructor(typeof(IUnitOfWork));
Run Code Online (Sandbox Code Playgroud)

我明白了

"类型'System.Object'上不存在匹配的构造函数."

我认为这是因为装配类型比我想象的要复杂一点,但问题仍然存在

我该怎么办?

c# autofac

3
推荐指数
1
解决办法
2430
查看次数

标签 统计

autofac ×1

c# ×1