Using StructureMap with Solrnet – updated

The implementation has now been updated to allow for multi-core instances. Which can be set up in your Bootstrapper like this:

var solr = (SolrConfigurationSection)ConfigurationManager.GetSection(“solr”);
var solrServers = solr.SolrServers;
x => x.AddRegistry(new SolrNetRegistry(solrServers))

You’re app config should look like the the following:

<section name="solr"
    type="StructureMap.SolrNetIntegration.Config.SolrConfigurationSection, SolrNet" />
<server id="myobject" url="http://localhost:8080/solr/"
documentType="Your.Objects.Name, Your.Objects.Namespace" />

9 Comments on “Using StructureMap with Solrnet – updated”

  1. Rob Ashton says:

    I really object to having to use app.config to drive my StructureMap configuration.

    It is for this reason I’m still not using this in our projects!

  2. Rob Ashton says:

    Sorry, that wasn’t very constructive, what I meant to say is really I’d prefer if the registry took in some bespoke configuration object that I could generate myself (basically by convention based on all of our cores/customers, as that is how we do most things), and then you could also generate that configuration object from app.config to allow that sort of thing as well.

    If that makes sense. Give us the choice at least 🙂

  3. […] The structuremap adapter now allows for multicore configuration Possibly related posts: (automatically generated)StructureMap RegistryThe IOC and (the Lack Of) […]

  4. Matt says:


    I’m pretty sure app.config has nothing to do with how StructureMap is configured (both in that example and in general).

    In fact that only line that has anything to do with it is this section:

    x => x.AddRegistry(new SolrNetRegistry(solrServers))

    The documentation recommends using the fluent DSL for type registration and has done for about the past 2 years. You can find it here:



  5. Rob Ashton says:

    That is not what I meant.

    var solr = (SolrConfigurationSection)ConfigurationManager.GetSection(“solr”);

    Is my problem, it’s not easy to construct those configuration objects manually, I don’t want to be storing my solr config in app.config

  6. Rob Ashton says:

    We generate *nearly all* of our StructureMap mappings via conventions, filling in the holes with some manual fluent config.

    I am not a simpleton who needs that explaining to me.

  7. Rob Ashton says:

    What I want to do is construct the configuration for Solr via convention too, because we have 100 customers, each with their own core(s), and they’re all named/setup via conventions. Sticking 100 cores in app.config is a faff.

  8. Matt says:

    The fact that Mark has chosen to use the app.config to hydrate his SolrConfigurationSection has nothing to do with SolrNet *or* StructureMap.

    There’s nothing to stop you from writing your own convention based mechanism to achieve this.

    Otherwise, I’m not sure what the point of your rant at Mark is…

  9. anonymus says:

    logging works without structuremap, but with structuremap how do we enable logging.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s