I'm trying to make a simple "Hello World" using MVC4 and Ninject.
I'm following: this tutorial
I'm using MVC4 and Visual Studio 2012 Web Express and I've installed the Nuget package using the following:
Install-package Ninject
Install-package Ninject.MVC3
I've got the following global.aspx:
public class MvcApplication : Ninject.Web.Common.NinjectHttpApplication
{
protected override Ninject.IKernel CreateKernel()
{
IKernel kernal = new StandardKernel();
kernal.Load(Assembly.GetExecutingAssembly());
kernal.Bind<IMessageService>().To<MessageService>();
return kernal;
}
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
}
}
When I run this I find that I get an exception thrown: Sequence contains no elements and VS tries to open the file NinjectHttpApplication.cs for debugging. VS can't find it though.
Any idea what's going on here?
Thanks
Dave
UPDATE
I've just tried the solution given in this question, which is to move the registering bindings to the the file in App_Start, this file was NinjectWebCommon.cs in my folder, there is no NinjectMVC3.cs file there.