注册程序集也是注册枚举
Registering an assembly is also registering enums
我在我的应用程序中使用 DRYIOC 作为 DI。我的 MVC 应用程序中有接口,我想将其注册到 dryIOC。所以我正在使用 RegisterMany,如下所示。
container.RegisterMany(new[] { Assembly.Load(DIAssemblyCollection["WebAssembly"]) },
serviceTypeCondition: type => type.IsInterface,
setup: Setup.With(allowDisposableTransient: true));
但我收到如下错误
Unspecified how to select single constructor for implementation type Web.Enums.Enum1 with 0 public constructors.
似乎是一个错误,但需要先查看代码。
同时,您可以只过滤实现类型,仅保留 类:
container.RegisterMany(
Assembly.Load(DIAssemblyCollection["WebAssembly"])
.GetLoadedTypes()
.Where(type => type.IsClass),
serviceTypeCondition: type => type.IsInterface,
setup: Setup.With(allowDisposableTransient: true));
更新
已在 DryIoc 2.7
中修复
我在我的应用程序中使用 DRYIOC 作为 DI。我的 MVC 应用程序中有接口,我想将其注册到 dryIOC。所以我正在使用 RegisterMany,如下所示。
container.RegisterMany(new[] { Assembly.Load(DIAssemblyCollection["WebAssembly"]) },
serviceTypeCondition: type => type.IsInterface,
setup: Setup.With(allowDisposableTransient: true));
但我收到如下错误
Unspecified how to select single constructor for implementation type Web.Enums.Enum1 with 0 public constructors.
似乎是一个错误,但需要先查看代码。
同时,您可以只过滤实现类型,仅保留 类:
container.RegisterMany(
Assembly.Load(DIAssemblyCollection["WebAssembly"])
.GetLoadedTypes()
.Where(type => type.IsClass),
serviceTypeCondition: type => type.IsInterface,
setup: Setup.With(allowDisposableTransient: true));
更新
已在 DryIoc 2.7
中修复