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 1096183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:14:40+00:00 2026-05-17T00:14:40+00:00

Having a problem with StructureMap IOC. I wish to retrieve different concrete implementations of

  • 0

Having a problem with StructureMap IOC. I wish to retrieve different concrete implementations of objects that implement the same interface based on labels or names.

internal static class InstanceHelper
{

    internal enum Taxonomy
    {
        Foo,
        Bar
    }

    static InstanceHelper()
    {
            // Initialize the container
            ObjectFactory.Initialize(x =>
            {
                x.For<IMyInterface>().Use<ObjectA>().Named(Taxonomy.Foo.ToString());
                x.For<IMyInterface>().Use<ObjectB>().Named(Taxonomy.Bar.ToString());
            });

    }

    internal static IMyInterface GetInstanceByTaxonomy(Taxonomy taxonomy)
    {

          // this raises an exception
          ObjectFactory.GetNamedInstance<IMyInterface>(taxonomy.ToString());

    }
}

Documentation is not to good in this regard, seems like all the examples out there are deprecated… using version 2.6.1.0

thanks.

  • 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-17T00:14:41+00:00Added an answer on May 17, 2026 at 12:14 am

    Both the original way and amarsuperstar’s way appears to actually work, the problem was that the scope of class ‘ObjectA’ had been declared as internal, along with an internal constructor. I changed this to Public and now IOC can see it… inverse reflection is happening within the StructureMap assembly. Doh silly me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having problem with null pointer exception and i read few article bout that error
I having problem marshaling an iterator of objects using JAXB User class: @XmlRootElement(name=User) public
I'm having problem with the date format of rails. It seems to me that
Having problem with jquery submit(). The problem is that it doesn't work on the
am having problem, my app doesn't seem to check the radio button based from
I am having this problem. I have integrated structuremap with wcf like it is
Having problem reading bytearray of custom objects. Any help is appreciated public class CustomObject
I am having problem to access JSONP array that is return by php script,
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Im having problem in my UIscrollView ,this is what I have done: Whenever a

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.