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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:41:24+00:00 2026-05-31T18:41:24+00:00

I have 4 projects: Core (IServer): System System.Core DependencyResolver: Core StructureMap Infrastructure (Service): Core

  • 0

I have 4 projects:

Core (IServer):

  • System
  • System.Core

DependencyResolver:

  • Core
  • StructureMap

Infrastructure (Service):

  • Core
  • External dependency

Console:

  • Core
  • DependencyResolver

Requierements:

I am trying to use StructureMap only in the DependencyResolver.
Furthermore the Console application should not know anything about Infrastucture.

When I do not want to reference StructureMap on my Console Application I have to build a ServiceLocator.

In the DependencyResolver I have a Bootstrapper that is responsible for calling StructureMap registry stuff (Register)

In my Console application I want to get an instance. For this I need to reference StructureMap. Another way would be to write a little wrapper around StructureMaps resolving methods.

Is there any other better way of decoupling the console from StructureMap?

  • 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-31T18:41:26+00:00Added an answer on May 31, 2026 at 6:41 pm

    While I see a reason for separating IoC register,resolve,release from the implementation of the application, I don’t see any reason why the IoC container shouldn’t be in the console application (the composition root) and the application implemention in another assembly instead.

    That way the console application is very easy:

    1. Create the container
    2. Load the container configuration
    3. Resolve the Application
    4. Call run on the application and pass the console arguments along
    5. dispose the container when the application exits the run method

    With SM it look about like this:

    public void Main(params string[] args)
    {
        using (var container = new Container())
        {
            container.LoadAllConfigurationModules();
            container.AddRegistry<SomeRegistry>();
            container.GetInstance<Application>().Run(args);
        }
    }
    

    For things you can’t create at startup you create a factory interface in your application assembly:

    interface ISomeFactory { ISomeDependency CreateSomeDependency() }
    

    and implement this interface in the console application by injecting the container and use it to resolve the instance. I guess the SM implementation looks like this:

    public class SomeFactory : ISomeFactory
    {
        public SomeFactory(IContainer sontainer) { this.container = container; }
        ISomeDependency CreateSomeDependency() { this.container.GetInstance<ISomeDependency>(); }
    }
    

    Other IoC container even have the functionallity to implement these interface factories automatically.

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

Sidebar

Related Questions

I have 4 projects: Client (Wpf Application) Server (Console Application) ClientServerInterface (Class Library) Core
I have 2 projects. One project is a core and contains the GUI which
I have a two projects, AI and Core , which used to hold a
I have two maven projects Project AAA AAA-Core AAA-Other Project BBB BBB-Core BBB-AAA-specific I
I have two projects: Project-Core Project-Source Project-Core POM.xml: <groupId>com.company</groupId> <artifactId>project-core</artifactId> <packaging>jar</packaging> <version>2.1</version> Project-Source POM.xml:
In my Solution I have the following projects MySystem.Core MySystem.Core.Data MySystem.MyAudit1.Core MySystem.MyAudit1.Core.Data MySystem.MyAudit2.Core MySystem.MyAudit2.Core.Data
I have few Core Data projects for MacOS started with Xcode 3 that behaves
VS2K8, C#. I currently have a solution with the following projects: Core - POCO
I have a central library (DLL) called Core that is used by many projects
I have a S#arp MVC application with following projects/layers : Core (Model) Data Web

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.