我正在try 注册我创建的一些端点,然而,Autofac抛出了一个异常,说我还没有注册我的BControl
类.这是我的注册码:
builder.RegisterType<GControlEndpoint>().As<IBusConsumer>().SingleInstance();
builder.RegisterType<BControlEndpoint>().As<IBusConsumer>().SingleInstance();
builder.RegisterType<BSControlEndpoint>().As<IBusConsumer>().SingleInstance()
.WithParameter((pi, c) => pi.Name == "bControlEndpoint",
(pi, c) => c.Resolve<BControlEndpoint>())
.WithParameter((pi, c) => pi.Name == "gControlEndpoint",
(pi, c) => c.Resolve<GControlEndpoint>());
我的BSControlEndpoint
代码如下:
private BControlEndpoint bControlEndpoint;
private GControlEndpoint gControlEndpoint;
public BSControlEndpoint(
BControlEndpoint bControlEndpoint,
GControlEndpoint gControlEndpoint)
{
this.bControlEndpoint = bControlEndpoint;
this.gControlEndpoint = gControlEndpoint;
}
任何帮助都将不胜感激.
Autofac错误为:
Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'Sa.BControlEndpoint' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
个