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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:49:14+00:00 2026-05-12T18:49:14+00:00

I am experiencing an issue with v1 of Ninject and resetting the StandardKernel. I

  • 0

I am experiencing an issue with v1 of Ninject and resetting the StandardKernel. I have a static object that I use to provide access to the kernel like so

public static class ObjectFactory
{
    private static IKernel _kernel =  new StandardKernel(new CanceisModule());

    // Resolve methods snipped for brevity

    public static void Reset()
    {
        _kernel = null;
        _kernel = new StandardKernel(new CanceisModule());
    }
}

The problem comes when I try to use ObjectFactory in various unit tests (I use MSTest) or fitnesse fixtures. I always call the ObjectFactory.Reset() method before every new test or fixture but sometimes it seems like the Reset doesn’t actually work and leaves the original bindings in place. I know there is a way to reset the IKernel objects in v2 of Ninject but we aren’t ready to make that move yet (and its a fairly significant move for us).

Could someone offer some advice on why this might be occuring? I’m guessing that it is related to the way tests are executed on separate threads in the different runners but how do I avoid it?

Thanks in advance

  • 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-12T18:49:14+00:00Added an answer on May 12, 2026 at 6:49 pm

    Your approach seems fine.

    In general, test runners don’t run multi threaded or anything magic like you’re guessing.

    I’d suggest putting a breakpoint in your Reset() and debugging your tests.

    Your code has a non-static method in a static class so is there something else you’re omitting to mention?

    When you say “new test or fixture”, which is it? Often it you are using Ninject in tests, it’s better to keep a kernel in a base class and make sure it’s reset at the right time to avoid any confusion or doubt [rather than relying on an object factory ‘singleton’].

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

Sidebar

Related Questions

I have an XP client that is experiencing an issue. My dev box is
I'm experiencing following issue: if I submit a form that contains checked value in
I'm offering a sermon downloading site and I have a user experiencing an issue
Experiencing an issue with an Ubercart 2 store that is now running on nginx.
We are currently experiencing an issue that requires the client endpoint configuration file to
I'm currently experiencing a strange issue that my understanding of SQL server doesn't quite
I'm experiencing an issue specific to Windows 8 and VS2012. I have a TCP
i am experiencing some issue with my application that I cant figure out how
I am experiencing an issue with a web app that is frequently spewing out
I was experiencing an issue with a repository that would error with a 'No

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.