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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:20:28+00:00 2026-05-27T16:20:28+00:00

By using Microsoft’s Unity, I am able to override a dependency in the exact

  • 0

By using Microsoft’s Unity, I am able to override a dependency in the exact moment that I’m resolving an instance, for example:

var valueObjectThatOverridesAnyConfiguration = new object();

var container = new UnityContainer();
container.Resolve<ATypeWithConstructorArguments>(new DependencyOverride(typeof(object), valueObjectThatOverridesAnyPreviousConfiguration);

That will override any previous configuration on my UnityContainer and inject the instance I provided on the DependencyOverride.

Is there a way to specify it in a Container level ? Like an extension or something ? I don’t want to do it at the resolve moment!

Thanks! Let me know if I’m being confuse to you, I’ll provide more info.

  • 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-27T16:20:29+00:00Added an answer on May 27, 2026 at 4:20 pm

    Do you mean something like this. The part that sounds like your problem starts in the middle of the thread.

    It allows you to do this

      var container = new UnityContainer();
      container.AddNewExtension<SemanticGroupExtension>();
    
      container.RegisterGroup<IVehicle, Car>("Car").Use<IWheel, CarWheel>().Use<IEngine, CarEngine>();
      container.RegisterGroup<IVehicle, Motorcycle>("Motorcycle").Use<IWheel, MotorcycleWheel>().Use<IEngine, MotorcycleEngine>();
    
      var car = container.Resolve<IVehicle>("Car");
      Assert.IsInstanceOfType(car.Wheel, typeof(CarWheel));
      Assert.IsInstanceOfType(car.Engine, typeof(CarEngine));
    
      var motorcycle = container.Resolve<IVehicle>("Motorcycle");
      Assert.IsInstanceOfType(motorcycle.Wheel, typeof(MotorcycleWheel));
      Assert.IsInstanceOfType(motorcycle.Engine, typeof(MotorcycleEngine));
    

    The sources can be found here inside the TecX.Unity project.

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

Sidebar

Related Questions

I am thinking about using Microsoft Unity for my Dependency Injection tool in our
I'm using Microsoft Visual C# 2008 Express. In my main form, there's that X
Using Microsoft Spy++, I can see that the following windows that belong to a
I am using Microsoft Visual Studio 2010 and C++ language that runs on the
Using Microsoft SQL Server 2008, let's say there is a table1 that keeps the
I am using a using Microsoft.FSharp.Core.Collections.FSharpMap and very often have to write: var oo
Using Microsoft Sql 2000 I have a requirement to be able to email a
using Microsoft.VisualStudio.CommandBars; In the following sample. var applicationObject = (DTE2)application; var allCommands = ((CommandBars)applicationObject.CommandBars);
I'm using Microsoft.Win32.OpenFileDialog in my WPF application for selecting file: var dlg = new
Using Microsoft's AntiXssLibrary, how do you handle input that needs to be edited later?

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.