我如何修复我的Castle Windsor登记?

时间:2016-08-05 13:02:55

标签: autofac castle-windsor

我已经非常努力地完成这项工作,但当我尝试从容器中解析IConfigReader时,它说我还没有注册任何组件。我一遍又一遍地读完它。百思不得其解!

var builder = new ContainerBuilder();
builder.RegisterType<ConsoleLogger>().As<ILogger>();
var output = new StringWriter();
builder.RegisterInstance(output).As<TextWriter>();
builder.Register(c => new ConfigReader("mysection")).As<IConfigReader>();
var container = builder.Build();

using(var scope = container.BeginLifetimeScope())
{
   var reader = container.Resolve<IConfigReader>();
}

0 个答案:

没有答案