我试图将OpenMap与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
我想也许我错过了注册?我可能做错了吗?
谢谢 -
答案 0 :(得分:0)
事实上,我似乎错过了注册。将此行添加到容器配置似乎已解决了该问题:
x.For<TraceSource>().Use(new TraceSource("OpenRasta"));
我不完全理解OR如何使用TraceSource,但是现在,我会开始工作!