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

  • Home
  • SEARCH
  • 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 605801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:11:08+00:00 2026-05-13T17:11:08+00:00

I personally like the option to configure StructureMap from C# code. From what I

  • 0

I personally like the option to configure StructureMap from C# code. From what I understand, one of the advantages of DI, is that we can easily swap in a new concrete instance. But, if the configuration is defined in code, then the concrete instances are hardcoded in the dll.

So, practically, its as good as having hard coded the dependencies, right? I know, during testing it makes life easier…

My point is, wouldnt it be better to use xml configuration instead? you want to plugin a new concrete instance? simply have your installer overwrite the structuremap.config file with the new one.

So, what is the preferred way to configure StructureMap?

Extra: Am forced to use C# configuration for the time being because I dont know how to pass the connection string to instance. I can write the connectionstring in the config file, but i would like to reuse the connectionstring defined in app.config.

  • 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-13T17:11:08+00:00Added an answer on May 13, 2026 at 5:11 pm

    No matter which particular DI Container you use, you should always defer the resolution of the application’s object graph to the last responsible moment. This is called the application’s Composition Root.

    You can write the bulk of your application without ever referencing the DI Container. This also means that you can defer the decision between configuration in code or config until you need it.

    You shouldn’t need the container at all for unit testing, but may need it for integration testing. However, in integration tests, you will likely need a different configuration for the container than in the final application.

    All in all, configuring the container in code is the preferred approach these days because it’s more robust and you can apply convention-based configuration mechanics.

    XML configuration tends to be more brittle and too verbose. In most cases, it simply slows you down because you get no refactoring or compiler support.

    However, XML configuration is still valid when you need to be able to swap dependencies without recompiling the application. Most DI Containers will let you mix those approaches so that you can have most of your configuration in code, but a few selected dependencies defined in XML for extensibility reasons.

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

Sidebar

Ask A Question

Stats

  • Questions 319k
  • Answers 319k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You know that the handle will typically change with each… May 14, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer from http://www.csharp-station.com/HowTo/HttpWebFetch.aspx HttpWebRequest request = (HttpWebRequest) WebRequest.Create("myurl"); // execute the… May 14, 2026 at 12:12 am
  • Editorial Team
    Editorial Team added an answer Two things: Copy constructors must take references as parameters, otherwise… May 14, 2026 at 12:12 am

Related Questions

Does anyone have any opinions over the best ways to connect a client to
I'm making an online dictionary. Now I have two options: 1) Use AJAX for
I have a Visual Studio C++ based program that uses pre-compiled headers ( stdafx.h
I personally like option one below for maintainability but I could see option two
I'm building an application with the following criteria: work items: items that need to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.