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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:15:53+00:00 2026-06-11T13:15:53+00:00

I’m currently testing some IoC frameworks for a project, and I’d love to be

  • 0

I’m currently testing some IoC frameworks for a project, and I’d love to be able to use Ninject 3.

I’m running into an issue where after I configure a binding to a concretely typed singleton, I can’t seem to effectively unbind the service type later on. That is, StandardKernel.TryGet<T>() returns a non-null value after calling StandardKernel.Unbind<T>(). See the snippet below for my exact usage.

Is this a bug in Ninject 3, or is there something I’m missing?

As a workaround, I can simply rebind the concrete type to a constant null value. But I’d prefer to understand if I’m not grokking something before I fallback to that position.

By the way, unbinding works as expected if I specify an interface bound to a concrete type in singleton scope, but not for a self bound concrete type in singleton scope. If this is not a bug (and for extra karma) can you explain why there is a difference in behaviour?

public class MyServiceType : IDisposable
{
    public bool IsDisposed { get; private set; }
    public void Dispose()
    {
        IsDisposed = true;
    }
}

static void Main(string[] args)
{
    var kernel = new StandardKernel();

    kernel.Bind<MyServiceType>().ToSelf().InSingletonScope();

    var instance = kernel.TryGet<MyServiceType>();
    Debug.Assert(instance != null && !instance.IsDisposed);

    // release the instance
    kernel.Release(instance);
    Debug.Assert(instance.IsDisposed);
    instance = null;

    // unbind the service
    kernel.Unbind<MyServiceType>();

    // uncomment below for workaround
    // kernel.Rebind<MyServiceType>().ToConstant((MyServiceType)null); 

    // after unbinding should no longer be able to get an instance of the service
    instance = kernel.TryGet<MyServiceType>();
    Debug.Assert(instance == null);  // <---- this is failing!
}
  • 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-11T13:15:55+00:00Added an answer on June 11, 2026 at 1:15 pm

    This is because Ninject will attempt to construct your object even if it is not bound. If it has a parameterless constructor, it will use that, otherwise it will try to construct it using dependencies found in the container.

    To prove this to yourself, even if you skip the initial binding of MyServiceType, and still do a TryGet, you will get an instance.

    Alternatively, you can try resolving the instance after it has been bound and released, and assert that they are infact different instances of the same class.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.