Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6353411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:24:26+00:00 2026-05-24T22:24:26+00:00

An approach we’ve taken recently is to include a StructureMap registry in each of

  • 0

An approach we’ve taken recently is to include a StructureMap registry in each of our assemblies that set’s up the default dependencies.

We use a scanner to do this:

        cfg.Scan(scanner =>
        {
            scanner.TheCallingAssembly();
            scanner.Assembly("Assembly1");
            scanner.Assembly("Assembly2");
            scanner.Assembly("Assembly3");

            scanner.LookForRegistries();
        });

The idea is that we can then override the default dependencies from the main application.

The question is, where should we register these overrides? i.e. before we scan?, after we scan?

Furthermore, does the order of the assemblies specified in the scan expression, effect the order in which the dependencies are registered. So in the example above, would registries contained in the main application (TheCallingAssembly) get overrided by those in “Assembly3”?

Many thanks
Ben

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:24:27+00:00Added an answer on May 24, 2026 at 10:24 pm

    Registries in TheCallingAssembly will be overridden by those you register in Assembly1, 2 etc.

    So if you register ISomeInterface in everyone of those assemblies, the one in Assembly3 will be the default. The ones registered in the others assemblies you can get from structuremap by calling

    container.GetAllInstances<ISomeInterface>();
    

    This will return a IList of all the registered ISomeInterface in structuremap.

    If you want to override the ones you get by scanning you have to configure the container again for some reason. If you don’t do that, the last scanned type is the default.

    In this example the ISomeInterface registered in Assembly1 is the default. When you look at the code, one would belive that SomeOtherClass is the default. But it is actually the one registered in Assembly1 that is the default.

    var container = new Container(x => {
                x.Scan(scanner =>
                {
                    scanner.TheCallingAssembly();
                    scanner.Assembly("Assembly1");
    
                    scanner.LookForRegistries();
                });
    
                x.For<ISomeInterface>().Use<SomeOtherClass>();
            });
    

    So to override the mappings from the scanned assemblies. You have to configure the container again like this example. Here SomeOtherClass is the default for ISomeInterface.

    var container = new Container(x => {
                x.Scan(scanner =>
                {
                    scanner.TheCallingAssembly();
                    scanner.Assembly("Assembly1");
    
                    scanner.LookForRegistries();
                });
            });
    
    container.Configure(x => x.For<ISomeInterface>().Use<SomeOtherClass>());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which approach is better to use: BoundField.NullDisplayText isn't set. NULL-case is foreseen in SQL
Which approach is better: 1) to use a third-party ORM system or 2) manually
Which approach is better to use if I need a member (sp or func)
General approach in GWT is to use Panels and then apply custom CSS themes
that approach in possible duplicate is different to the one in the book. The
Our application follows the approach of maintaining a DataContext per Thread/HttpContext, using the DataContextFactory
What is a best approach to make a function or set of statements thread
Approach #1: DECLARE @count int SET @count = 2000 DECLARE @rowcount int SET @rowcount
How can I approach a Joomla plugin (I assume) that can parse and format
What is the best approach for implementing a single-use password to download a file?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.