ninject/Ninject.Web.Mvc

OnePerRequestHttpModule does not perform its cleanup work

ydie22 opened this issue · 1 comments

When installing the latest nuget package (3.2.1), I noticed that disposable components in request scope were no longer properly cleaned up (Dispose() not called at request end). When downgrading to 3.2.0, all is fine. After looking at the code, it seems that MvcModule no longer inherits from GlobalKernelRegistrationModule, but directly from NinjectModule. Consequently, the kernel instance is no longer in GlobalKernelRegistration, and the MapKernels call in OnePerRequestHttpModule has no effect.
Am I missing something (some config, or module to load)? Or is it an issue in the generated code when installing the nuget package? Or possibly a bug?

The issue seems to actually come from nuget package dependencies, not from the code. Version 3.2.1 of the mvc package should apparently require higher version of web.common package to function properly.
Here below is an excerpt of the nuget console that shows the installed packages when requesting ninject.mvc5. When installing all the latest versions of the dependencies one by one, there is no issue.
PM> install-Package ninject.mvc5
Attempting to resolve dependency 'Ninject (≥ 3.2.0.0 && < 3.3.0.0)'.
Attempting to resolve dependency 'Ninject.Web.Common.WebHost (≥ 3.0.0.0)'.
Attempting to resolve dependency 'Ninject.Web.Common (≥ 3.2.0.0 && < 3.3.0.0)'.
Attempting to resolve dependency 'WebActivatorEx (≥ 2.0 && < 3.0)'.
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.
Installing 'Ninject 3.2.0.0'.
You are downloading Ninject from Ninject Project Contributors, the license agreement to which is available at https://github.com/ninject/ninject/raw/master/LICENSE.txt. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Ninject 3.2.0.0'.
Installing 'Ninject.Web.Common 3.2.0.0'.
You are downloading Ninject.Web.Common from Ninject Project Contributors, the license agreement to which is available at https://github.com/ninject/ninject.extensions.wcf/raw/master/LICENSE.txt. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Ninject.Web.Common 3.2.0.0'.
Installing 'WebActivatorEx 2.0'.
Successfully installed 'WebActivatorEx 2.0'.
Installing 'Ninject.Web.Common.WebHost 3.2.0.0'.
You are downloading Ninject.Web.Common.WebHost from Ninject Project Contributors, the license agreement to which is available at https://github.com/ninject/ninject.web.common/raw/master/LICENSE.txt. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Ninject.Web.Common.WebHost 3.2.0.0'.
Installing 'Ninject.MVC5 3.2.1.0'.
You are downloading Ninject.MVC5 from Remo Gloor, Ian Davis, the license agreement to which is available at https://github.com/ninject/ninject.web.mvc/raw/master/mvc3/LICENSE.txt. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Ninject.MVC5 3.2.1.0'.
Adding 'Ninject 3.2.0.0' to WebApplication1.
Successfully added 'Ninject 3.2.0.0' to WebApplication1.
Adding 'Ninject.Web.Common 3.2.0.0' to WebApplication1.
Successfully added 'Ninject.Web.Common 3.2.0.0' to WebApplication1.
Adding 'WebActivatorEx 2.0' to WebApplication1.
Successfully added 'WebActivatorEx 2.0' to WebApplication1.
Adding 'Ninject.Web.Common.WebHost 3.2.0.0' to WebApplication1.
Successfully added 'Ninject.Web.Common.WebHost 3.2.0.0' to WebApplication1.
Adding 'Ninject.MVC5 3.2.1.0' to WebApplication1.
Successfully added 'Ninject.MVC5 3.2.1.0' to WebApplication1.