我很抱歉用我的小问题来打扰社区,但是我被卡住了!
在我们了解详细信息之前,这里是我的服务模块容器设置!
public class ServiceModule : Module
{
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.Register(c => new ContextService(c.Resolve<IContextDataProvider>(),
c.ResolveNamed<IExceptionShield>("SRV_HOST_SHIELD"),
c.Resolve<IMonitoring>()))
.As<IContextService>();
builder.Register(c => new ExceptionShield(
c.ResolveNamed<IShieldConfiguration>("SRV_SHIELD_CONFIG")))
.Named<IExceptionShield>("SRV_HOST_SHIELD");
builder.Register(c => new ServiceExceptionShieldConfiguration()).Named<IShieldConfiguration>("SRV_SHIELD_CONFIG");
builder.RegisterType<ContextService>().Named<object>("Service.ContextService");
}
}
我一直在犹豫的问题是,服务构造函数的第二个参数不能
断然的
.
我已经尝试了所有的排列,对我来说,包括简单地初始化没有容器解析的参数。但所有的结尾都是同一个例外:
None of the constructors found with 'Public binding flags' on type 'Service.ContextService' can be invoked with the available services and parameters:
Cannot resolve parameter 'Common.ExceptionShield.IExceptionShield exceptionShield' of constructor 'Void .ctor(IContextDataProvider, Common.ExceptionShield.IExceptionShield, Common.Monitoring.IMonitoring)'.
我一定错过了一些重要的东西。如果你看到我的错误,请告诉我:)