4
我得到錯誤Ninject - 資源無法找到
的資源不能被發現。
當我嘗試在我的MVC-3應用程序中實現Ninject時。如果我把上面出來的代碼,並恢復到System.Web.HttpApplication
然後事情開始重新工作的問題出現在CreateKernel()
#region Inversion of Control
protected override IKernel CreateKernel()
{
return Container;
}
static IKernel _container;
public static IKernel Container
{
get
{
if (_container == null)
{
_container = new StandardKernel(new SiteModule());
}
return _container;
}
}
internal class SiteModule : NinjectModule
{
public override void Load()
{
bool MOCKDB = true;
//MOCKDB = false;//Stop Mocking
if (MOCKDB)
{
//Set up mock bindings
Bind<iItem>().To<LeadServiceMock>();
}
else
{
//Set up real bindings.
Bind<iItem>().To<LeadService>();
}
}
}
#endregion
從Global.asax中來。
public class MvcApplication : NinjectHttpApplication//:System.Web.HttpApplication
{
我從以前的實現中拿出了這段代碼,這個代碼也是可以的。如果我通過調試
protected override IKernel CreateKernel()
{
return Container;
}
步驟我都的工作程序得到一個錯誤,這打破一個:
Locating source for 'c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectHttpApplication.cs'. Checksum: MD5 {b8 b2 52 86 ce 34 de 53 61 76 c9 df ff 65 8c 3f}
The file 'c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectHttpApplication.cs' does not exist.
Looking in script documents for 'c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectHttpApplication.cs'...
Looking in the projects for 'c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectHttpApplication.cs'.
The file was not found in a project.
Looking in directory 'c:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'c:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'c:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'c:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectHttpApplication.cs.
The debugger could not locate the source file 'c:\Projects\Ninject\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectHttpApplication.cs'.
我懷疑我做了錯誤的成纔在SiteModule
。我究竟做錯了什麼?