我正在开发 SolrNet 4.0。Solr 中有多核实现。我使用 Autofac 作为 IoC。
var cores = new SolrServers
{
new SolrServerElement
{
Id = "entity1",
DocumentType = typeof(Entity1).AssemblyQualifiedName,
Url = "http://localhost:8983/solr/coreEntity1",
},
new SolrServerElement
{
Id = "entity2",
DocumentType = typeof(Entity2).AssemblyQualifiedName,
Url = "http://localhost:8983/solr/coreEntity2",
},
};
builder.RegisterModule(new SolrNetModule(cores));
var container = builder.Build();
var solrOperations1 =
container.ResolveNamed<ISolrOperations<Entity1>>("entity1");
var solrOperations2 =
container.ResolveNamed<ISolrOperations<Entity2>>("entity2");
以上是将核心注册到 IoC 中。但是当我从该容器中解析时,出现如下错误。
请求的服务 'entity1 (SolrNet.ISolrOperations`1[[Entity1, TestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]])' 尚未注册。为避免此异常,请注册组件以提供服务,使用 IsRegistered() 检查服务注册,或使用 ResolveOptional() 方法解决可选依赖项。
我在代码中做错或遗漏了什么吗?
谢谢。