0

我正在尝试将 StructureMap 与 OpenRasta 一起使用。我的Configuration班级实现IDependencyResolverAccessor. 这是我配置容器的代码:

container.Configure(x =>
     {
         x.For<IFileResourceRepository>().Use(
             r => new FileResourceSqlRepository(ConnectionString));
         x.For<ILog>().Use(l => new FileLog(LogFileName, _logLevel));
         x.For<ILogger>().Use<ProTeckLogger>();
         x.For<ILogger<CodecLogSource>>().Use<ProTeckLogger<CodecLogSource>>();
         x.For<ILogger<IOLogSource>>().Use<ProTeckLogger<IOLogSource>>();
         x.For<ILogger<OperationModelLogSource>>().Use<ProTeckLogger<OperationModelLogSource>>();
         x.For<ILogger<PipelineLogSource>>().Use<ProTeckLogger<PipelineLogSource>>();
         x.SetAllProperties(
             policy =>
             policy.Matching(
                 prop => (prop.PropertyType.IsAssignableFrom(typeof (ILogger)))));
         x.SetAllProperties(policy => policy.OfType<IFileResourceRepository>());
         x.SetAllProperties(policy => policy.OfType<ILog>());
         x.SetAllProperties(policy => policy.OfType<ILogger<CodecLogSource>>());
         x.SetAllProperties(policy => policy.OfType<ILogger<IOLogSource>>());
         x.SetAllProperties(policy => policy.OfType<ILogger<OperationModelLogSource>>());
         x.SetAllProperties(policy => policy.OfType<ILogger<PipelineLogSource>>());
     });

我收到以下错误:

StructureMap Exception Code:  202
No Default Instance defined for PluginFamily System.Diagnostics.TraceSource, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

我想也许我错过了注册?我可能做错了什么吗?

谢谢-

4

1 回答 1

0

实际上,我似乎错过了注册。将此行添加到容器配置中似乎已经解决了该问题:

 x.For<TraceSource>().Use(new TraceSource("OpenRasta"));

我不完全了解 OR 如何使用 TraceSource,但现在,我将开始工作!

于 2012-04-09T21:15:48.543 回答