I have installed vs2012 (11.0.50727.1)
,
I opened a new MVC4 with .NET 4.5
solution,
i create a simple HomeControl
Old post but if you encounter it prior to the mvc woes (System.Mvc.dll update e.g x.0.0.1) you could check the bindingRedirect tag(4.0.0.0 -> 4.0.0.1)
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.1" />
</dependentAssembly>
I faced this problem and solved it by
1. uninstall-Package Microsoft.AspNet.Mvc (I need to uninstall something else before I can uninstall AspNet.MVC successfully)
2. Install-Package Microsoft.AspNet.Mvc -Version 4.0.20710
3. Rebuild and deploy
The same error appears when you switch you project from MVC3 to MVC4 and forget to change System.Web.WebPages.Razor, Version=1.0.0.0
to System.Web.WebPages.Razor, Version=2.0.0.0
in the web.config.
Old post but just to add for anyone looking
This seems like a catch all error. I got it when my web.config used an external section and that section was excluded from the Visual Studio project, i.e. using this
<sessionState configSource="SystemWeb.config" />
Just update "System.Web.Mvc" with "nuget"
Do you have something like this in your Global.asax.cs?
private static void InitializeDependencyInjectionContainer(HttpConfiguration config)
{
container = new UnityContainer();
container.RegisterType<Site.Web.Data.IDatabaseFactory, Site.Web.Data.DatabaseFactory>();
container.RegisterType<Site.Web.Data.Interfaces.IUnitOfWork, Site.Web.Data.UnitOfWork>();
container.RegisterType<Site.Web.Data.Interfaces.IUserRepository, Site.Web.Data.Repositories.UserRepository>();
container.RegisterType<Site.Web.Data.Interfaces.ISiteRepository, Site.Web.Data.Repositories.SiteRepository>();
From the stack trace you posted System.Web.Mvc.IDependencyResolver.GetService(Type serviceType) +0
would suggest one (or more) of your dependencies don't resolve.
You could try commenting one or more of them out and try to narrow down which one is failing to resolve.