Ninject 2.2.1.0 and Ninject.MVC3 2.2.1.0 released

I just released Ninject 2.2.1.0 and Ninject.MVC3 2.2.1.0. Both are bugfix releases. In this Blogpost I’ll explain if you have to update and what changes you need to do in case you are using th NuGet version of Ninject.MVC3.

Ninject 2.2.1.0
This version fixes a bug for the .NET 4.0 and SL 4.0 versions of Ninject. The .NET framework still seems to have a bug when you request the attributes of an indexer property that is overridden in a derived class. For more information see the bug report at Microsoft. For 2.2.1.0 I switched back to our custom implementation that we already used in 3.5 for retrieving attributes of properties to workaround this problem.

This means you have to update to 2.2.1.0 only if you are using one of the .NET 4.0 or Silverlight 4.0 releases. This release changes absolutely nothing for the .NET 3.5 versions of Ninject.

Ninject.MVC3 2.2.1.0
This release fixes two bugs. The first one applies to everyone. The second only for NuGet package users.

  1. Websites with heavy load will start to crash with an circular reference exception after some time.
  2. The NuGet package version disposes the kernel unintended.

Furthermore, I changed the NuGet package to use the new Naming Convention of the WebActivator and switched to WebActivator 1.4. This change requires that you move the CreateKernel and RegisterServices methods from NinjectHttpApplicationModule to AppStart/Ninject.MVC3 and that you delete the NinjectHttpApplicationModule afterwards.

Other Extensions
You may ask yourself where you find the other extensios for 2.2.1.0. The answer is, there are no new ones. The old ones are still valid for Ninject 2.2.1.0 as we changed the build system to leave the assembly version at 2.2.0.0 as long as there is no interface change that requires an update of the extensions.

About the author

Remo Gloor

My name is Remo Gloor and Iā€™m working as a software architect at bbv Software Services AG in Zug, Switzerland. My first expiriences with computers were a a little boy with basic programming on a C64, later Pascal an C on an Intel 8080. After finishing my study in software engineering I started working with C#.

Currently, I'm one of two Main Developers of the well known Ninject IoC containers. My other interests beside Ninject are TDD, Scrum and software architecture in general.

15 comments

  • Hi, would you please update the package and rename/fix the AppStart folder in the current Ninject package to App_Start. The convention all the other packages and David Ebbo uses is *App_Start*. Thanks!

  • If I create a new MVC3 web application and add Ninject.MVC3. It can’t find Microsoft.Web.Infrastructure and i have to add it manually. Is there a way to automate/fix this?

  • @Scott: Done
    @JJoos: The reference is added if NuGet and PowerShell is properly installed on your system.

  • Please explain which Nuget package to install as MVC3 RTM installed on top of vs 2010 allows the package manager to work just fine. Most downloads work just fine. However, I know that if I contribute software, I make sure it works on more than 1 computer, and when someone has a question I am not going to give a reply that shouts “It works for me, re-install …” ughhh

    Microsoft.Web.Infrastructure does not exist, please try as provide a better reply than “NuGet and PowerShell is properly installed”
    Thanks.

    That or time to jump ship, many other IOC out there.

  • It is this sort of attitude which kills open source projects. Remo Gloor is spending countless hours in maintaining and improving Ninject and the extensions. Our company spends time and money to keep the product maintained and accurate.

    Nobody keeps you from forking the source and investigating yourself into the problem. When you detected the issue send a pull request to us. That’s the nature of open source. We and especially Remo have a life outside of ninject, imagine that šŸ˜‰

    By the way. If you claim yourself a good package developer and software contributor: Why don’t you spend some of your testing resources to the ninject project? I’m sure we would find some way to automatically deploy the packages to one of your remote computers and then you could “ensure that it works on more than 1 computer”. And only after you have given us green light we would provide the packages on Nuget and the website. Think about that…

    Daniel

  • You may are a good package developer. But you are defenately not good at keeping your tools up to date and following the solution you were told.

    MVC3 RTM does not contain the latest NuGet which is 1.1 at the moment. And believe me, the package is testes on far more than just one system. But as the package uses 1.1 features, I won’t test on a 1.0 system as I know that it doesn’t work.

    So, as a user of a open source project, I would rather do as I was told and update my system before I write a rude comment that the proposed solution does not work!

  • HI,
    i just installed the package in my MVC3 app.
    When I set up NinjectMVC3.cs, I try to call the ninject in global.asax like this in Application_Start method
    NinjectMVC3.Start();
    I allways get error:
    This method can only be called during the application’s pre-start initialization stage
    Can you please help me

    Tnx
    Ufi

  • Hey there, Remo. I’m a big fan of Ninject, and I think it’s one of the best products I’ve used next to Fluent nHibernate itself – though this newest release has me exceptionally confused.

    I’m not trying to critisize or complain, really – but I really don’t get the point of this “NinjectMVC3.cs” file in this newly created “App_Start” directory. Out of the box, it doesn’t even run, and adding the right references to make it run seems a bit counter-intuitive to the ‘simplicity’ aspect of Ninject.

    I don’t really get what it does. Even in your own Example Project (https://github.com/ninject/ninject.web.mvc/tree/master/mvc3/src/SampleApplication) You do not utilize this class.

    Could you enlighten me a bit on what is going on here? I’m really OCD, and picky about my code, I like to understand as much as possible.

  • Hi

    I’m working onNinject.Extensions.Wcf 3.0.0.0.
    In developing environment NinjectWebCommon work ok,
    but when i deploy on server, it seen this class doesn’t run.

    Here is error, could you please help me verify it?

    Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
    Ciiva.Server.Base.WCFServiceBase.get_FarmDbContext() +135
    Ciiva.Server.DomainAdministrationServices.DomainAdministrationService..ctor(IUserService _repoUser, IGroupService _repoGroup, ICommonService _repoCommon, IDomainDatabaseService _repoDomain) +192
    DynamicInjectorf8bfd6b3958a419cb6eb6ac7e0a8cc95(Object[] ) +211
    Ninject.Activation.Context.Resolve() +279
    System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +237
    System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +298
    System.Linq.WhereSelectArrayIterator`2.MoveNext() +109
    System.Linq.Buffer`1..ctor(IEnumerable`1 source) +487
    System.Linq.Enumerable.ToArray(IEnumerable`1 source) +103
    Ninject.Activation.Providers.StandardProvider.Create(IContext context) +778
    Ninject.Activation.Context.Resolve() +279
    System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +237
    System.Linq.Enumerable.Single(IEnumerable`1 source) +281
    Ninject.Extensions.Wcf.BaseNinjectServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +224
    System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +529
    System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1412
    System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +49
    System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1171

    [ServiceActivationException: The service ‘/Server/DomainAdministrationService.svc’ cannot be activated due to an exception during compilation. The exception message is: Object reference not set to an instance of an object..]
    System.Runtime.AsyncResult.End(IAsyncResult result) +901424
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
    System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107

By Remo Gloor

Recent Posts