0

I'm working on SolrNet 4.0. There are multicore implementation in Solr. I'm using Autofac as 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");

above is registration of cores into IoC. But when I resolve from that container, got an error like below.

The requested service 'entity1 (SolrNet.ISolrOperations`1[[Entity1, TestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]])' 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.

Am I doing wrong or missing something in code?

Thanks.

Steven
  • 166,672
  • 24
  • 332
  • 435
Dharmik Bhandari
  • 1,702
  • 5
  • 29
  • 60
  • 1
    This is your exact code? Because basically it is the same as the `ResolveSolrOperations_viaNamedWithMultiCore` https://github.com/mausch/SolrNet/blob/master/AutofacContrib.SolrNet.Tests/AutofacMulticoreFixture.cs#L107 unit test so it should just work... – nemesv Jun 01 '13 at 07:46
  • yes. this is exact code. but not working on my side. – Dharmik Bhandari Jun 01 '13 at 07:49
  • What happens inside SolrNetModule? – Travis Illig Jun 01 '13 at 16:57
  • 1
    @TravisIllig the source is on github: https://github.com/mausch/SolrNet/blob/master/AutofacContrib.SolrNet/SolrNetModule.cs – nemesv Jun 01 '13 at 18:44
  • Deleted my answer from earlier; tested stuff out and I was incorrect. – Travis Illig Jun 02 '13 at 07:21
  • I was going to try to repro the issue but it doesn't seem the NuGet packages for SolrNet are the same version of things that work with the source for the Autofac integration library there. For example, the Autofac module references `DefaultResponseParser<>` which isn't in the NuGet version. I tried really simple possibly not apples-to-apples repro and can't get the message to come up, so I'm guessing there's possibly something else going on. – Travis Illig Jun 02 '13 at 07:54
  • I think SolrNetModule is not register properly. Am I right? – Dharmik Bhandari Jun 03 '13 at 06:42

0 Answers0