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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:46:24+00:00 2026-06-07T05:46:24+00:00

So I read the Dependency Injection in .NET book not long ago. Trying to

  • 0

So I read the Dependency Injection in .NET book not long ago. Trying to use DIC now. However, I have something I don’t quite understand. Two examples:

1. if I have some old code or a 3rd party dll that uses a singleton static method like this:

var objTool = ThirdPartyTool.GetInstance();
objTool.DoStuff();
...

2. if I have some code in a method creating a temp object:

var tempOrder = new Order();
tempOrder.Total = strArray.[0];
tempOrder.ItemId = strArray.[1];
tempOrder.ShipAddress = strArray[2];
if(Customer.HasConfirmedOrder) { Customer.Order = tempOrder; }
 ...

In both cases, before I enter the DIC world, I know those objects will naturally be GC collected when they are out of scope, or if there is a Dispose() to call, I am responsiable to call it somewhere after I use the object.

How does DIC treat them? (I am running Ninject on a .NET 4 MVC 3 project, but I guess other languages/projects and DICs have pretty much the same structure)

  • 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-06-07T05:46:25+00:00Added an answer on June 7, 2026 at 5:46 am

    If an object is not managed by the DI framework, as the example you provided, it is your responsibility to manage its lifetime and if necessary call Dispose on it (especially if this object implements IDisposable)

    So to answer your question:

    How does DIC treat them?

    It doesn’t treat them at all. The DI framework doesn’t even know of their existence.

    The DI framework is responsible for managing objects that you explicitly registered with it.

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

Sidebar

Related Questions

I'm trying to use Dependency Injection and Factory class. I've read quite a bit
How do we identify when to use dependency injection or singleton pattern. I have
I have started to use Autofac following this tutorials: http://flexamusements.blogspot.com/2010/09/dependency-injection-part-3-making-our.html Simple class with no
After all what I have read about Dependency Injection and IoC I have decided
I have read a lot of articles on Dependency Injection as well as watched
Over the past few days i read a lot about Dependency Injection. Now since
I have read about IOC/DI for dependency injection. It says to create interfaces of
I have read about continuency parser and dependency parser. but confused which could be
Possible Duplicate: What is dependency injection? I've read the Wikipedia page. I've read an
In past couple of days, I have read about quite a lot about dependency

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.