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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:04:18+00:00 2026-05-19T22:04:18+00:00

I have my Unity configured to be able to resolve several types with my

  • 0

I have my Unity configured to be able to resolve several types with my own lifetime manager (per http request). Now in one special initialization method I need to get fresh instances of resolved types structure and I don’t want these instances to be stored and reused for subsequent Resolve calls = for this special method I need transient lifetime manager.

I want to avoid second container configuration because it will be copy of the first one with different lifetime managers. Is it possible somehow override lifetime manager configuration when resolving the type?

This question is realted to my previous question because I’m looking for better way to do that.

Edit:

I know that I can create multiple named registrations but that whould require creating big part of configuration again just because of changing lifetime manager.

  • 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-19T22:04:19+00:00Added an answer on May 19, 2026 at 10:04 pm

    I think – as you have noted – we can use two separate registrations with tow different lifetime configurations. But you seem not to be happy with this setup and you would like to pass the lifetime at the time of registration.

    My suggestion is to create an extension method which takes an additional lifetime and checks the container for such registration and if it does not exist, it registers it and returns with the setup you require.

    But to be honest, I do have a problem with this approach, even if such a method existed in the framework. IoC containers remove the knowledge of the dependant on the dependency but you are adding this knowledge back to the client/dependant which against the IoC principle.

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

Sidebar

Related Questions

I'm using the Unity MVC3 code at http://unitymvc3.codeplex.com/ to have a NHibernate session per
I have MVC webApi application which works with Unity . I have to resolve
I have an configuration error with Unity. I am trying to implement http://unitymvc3.codeplex.com/ ,
I have a little problem resolving types with Unity. There's an example of what
I have a unity container that's configured via a XML file. After it's configured
I have troubles consuming unity container in ASP.NET MVC3 application. I have several project
Can Unity automatically resolve IEnumerable<T> ? Let's say I have a class with this
In my WCF web application I have configured the Unity container for Interception. Following
I have one persistence unit configured in my persistence.xml but i have two databases.
Using Unity in an ASP.Net MVC 2 app I have various dependencies on Controllers

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.