将Ninject.MVC3添加到现有的MVC(4)项目中

rei*_*den 9 asp.net-mvc ninject

我正在使用MVC4开发一个项目,并决定我希望通过Ninject添加一些依赖注入.通过NuGet下载/安装后,我在NinjectWebCommon.cs(第23行)中发现了这个错误:

The type 'System.Web.IHttpModule' is defined in an assembly 
that is not referenced. You must add a reference to assembly 
'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Run Code Online (Sandbox Code Playgroud)

然后稍后(第44行):

The type or namespace name 'IHttpModule' could not be found 
(are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)

我希望这通常有效,但事实上,当我将Ninject添加到项目中时,我做了一些不起作用的事情.

编辑:上述错误仅由测试项目抛出....

小智 22

确保在main和test项目中指定System.Web引用.测试项目有自己的维护参考列表.我希望你在测试项目中没有System.Web.