I have a ASP.NET WebForms application that uses some Ninject packages, but I am stuck at a certain version. When I try to upgrade to the latest version, I get \"Unable to r
Okay, so this is how to fix:
Ninject.Web
package completely. This package is no longer required as it is now integrated into Ninject.Web.Common
(well, version v3.3+ anyway)Ninject
, Ninject.Web.Common
and Ninject.Web.Common.WebHost
. These should now upgrade okay. For me, they are both v3.3.1.App_Start\Ninject.Web.Common.cs
will have been added. This is just a rename of the existing App_Start\NinjectWeb.Common.cs
so either [a] delete the new file or [b] migrate over your Ninject module registrations and remove the old file.In web.config
, you should now remove the OnePerRequestModule
module:
This is because this module, is registered dynamically on loadup in the App_Start\Ninject.Web.Common.cs
file's Start()
method:
public static void Start()
{
DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
bootstrapper.Initialize(CreateKernel);
}
If you don't remove this entry from web.config then you can expect a type exception when launching your application, not least because as part of the version update, the class has moved from the Ninject.Web.Common
namespace to Ninject.Web.Common.WebHost
.
You can also remove the file App_Start\NinjectWeb.cs
for the same reason (registering NinjectHttpModule
)
If OnePerRequestHttpModule
doesn't resolve in App_Start\Ninject.Web.Common.cs
then add the following using statement to the file using Ninject.Web.Common.WebHost;
(I think this is a missing reference in v3.3.1 of the package.
Hope this helps others.