使用 NuPack 插件并安装 NInject MVC 3 包会在生成的NinjectMVC3.cs
文件中导致以下编译错误。
The name 'MvcServiceLocator' does not exist in the current context
David Ebbo 发布的示例视频显示它在 09:43 工作得很好。
这是当前生成的类:
public class NinjectMVC3 {
public static void RegisterServices(IKernel kernel) {
//kernel.Bind<IThingRepository>().To<SqlThingRepository>();
}
public static void SetupDependencyInjection() {
// Create Ninject DI Kernel
IKernel kernel = new StandardKernel();
// Register services with our Ninject DI Container
RegisterServices(kernel);
// Tell ASP.NET MVC 3 to use our Ninject DI Container
MvcServiceLocator.SetCurrent(new NinjectServiceLocator(kernel));
}
}