找不到System.Web.Mvc版本

时间:2015-08-21 21:05:25

标签: c# asp.net-mvc visual-studio-2013

编译MVC应用程序后收到以下错误。

[FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]

[FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   HNZPartsExtract.PHAWeb.MvcApplication.Application_Start() in d:\test\CCA GMOV\HNZPartsExtract\HZAPartsExtract.PHAWeb\Global.asax.cs:19

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12601341
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Could not load file or assembly 'System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618388
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458005

我添加了4.0版作为参考,所以我不确定为什么会收到该错误。我没有5.2,但看起来我需要5.2 ..但是,我无法在当前的开发环境中安装NuGet包,所以我不确定如何下载该DLL并在没有NuGet的情况下添加它。 / p>

2 个答案:

答案 0 :(得分:1)

如果项目在VS2013中启动,则默认模板引用MVC5,因此即使您向4.0二进制文件添加程序集引用,您的web.config仍然引用5.x(x代表当前的当前任何内容)项目已创建)。

您可以在此处下载MVC包:https://www.nuget.org/packages/Microsoft.AspNet.Mvc/然后解压缩.nupkg存档(使用7zip或类似文件)以获取.dll文件。

如果您不使用NuGet的原因是因为您使用的是没有NuGet支持的旧版Express,请升级到Community Edition。假设您拥有最新的WPI(Web平台安装程序),它在“工具”部分下列出,或者您可以从https://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx下载。

答案 1 :(得分:0)

你已经尝试过了吗?复制Local = True

Did you already try this?