简体   繁体   English

出现错误-无法加载文件或程序集'System.Web.Mvc,版本= 4.0.0.0

[英]getting error-could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0

Accidently I had deleted a reference of System.Web.Mvc of version "5.0.0.0" in my web api project,now when I tried to build it,it successfully builds and adds a dll of of System.Web.Mvc of version "4.0.0.0".Now when I run it I got error 偶然地,我在Web api项目中删除了版本“ 5.0.0.0”的System.Web.Mvc的引用,现在当我尝试构建它时,它成功地构建并添加了版本“ System.Web.Mvc的dll”。 4.0.0.0“。现在,当我运行它时出现错误

Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 无法加载文件或程序集'System.Web.Mvc,版本= 4.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。

In my web config following lines are written 在我的网络配置中,编写了以下几行

<dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
<dependentAssembly>

When i remove the auto added dll of 'System.Web.Mvc' and adds a dll of 'System.Web.Mvc, Version=5.0.0.0' from my nuget packages 'Microsoft.AspNet.Mvc.5.0.0' error disappears. 当我删除自动添加的'System.Web.Mvc'dll并从我的nuget包'Microsoft.AspNet.Mvc.5.0.0'添加dll的'System.Web.Mvc,Version = 5.0.0.0'错误消失时。

My question is from which location i should add my deleted dll or how to restore my accidently deleted dll? 我的问题是我应该哪个位置添加删除的dll或如何恢复意外删除的dll?

My question is from which location i should add my deleted dll or how to restore my accidently deleted dll? 我的问题是我应该从哪个位置添加删除的dll或如何恢复意外删除的dll?

There are two action here: 这里有两个动作:

  1. If you deleted the dll itself 如果您删除了dll本身

  2. If you have deleted a reference to the dll 如果您删除了对dll的引用

To handle first case, you will have to restore the Nuget package, that's it. 要处理第一种情况,您将必须还原Nuget包。 For more information on package restore, check this link 有关软件包还原的更多信息,请检查此链接

To handle second case which you mentioned in your question in very first line, just add a reference to the dll. 要处理在第一行中提到的第二种情况,只需添加对dll的引用。 The dll location is same as where you Nuget package is downloaded. dll的位置与您下载Nuget软件包的位置相同。

Hope this helps. 希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载文件或程序集“ System.Web.MVC,版本4.0.0.0” - could not load file or assembly 'System.Web.MVC, version 4.0.0.0,' 无法加载文件或程序集System.Web.Mvc,版本= 5.2.3.0 - Could not load file or assembly System.Web.Mvc, Version=5.2.3.0 使用Autofac获取错误“无法加载文件或程序集&#39;system.web.mvc版本= 5.1.0.0” - Using Autofac get error “could not load file or assembly 'system.web.mvc version=5.1.0.0” 无法加载文件或程序集“System.Web.Mvc,版本=4.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35” - Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 无法在MVC 5中加载文件或程序集&#39;System.Web.Mvc&#39; - Could not load file or assembly 'System.Web.Mvc' in mvc 5 无法在单元测试中加载文件或程序集&#39;System.Web.Mvc - Could not load file or assembly 'System.Web.Mvc In Unit Test 无法加载文件或程序集System.Web.Mvc - Could not load file or assembly System.Web.Mvc 无法加载文件或程序集 'System.Web.Services,版本 = 4.0.0.0 - Could not load file or assembly 'System.Web.Services, Version=4.0.0.0 无法在“新”框中加载文件或程序集&#39;System.Web.Mvc,版本= 3.0.0.0 - Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0 on NEW box 无法在服务器上加载文件或程序集&#39;System.Web.Mvc,Version = 3.0.0.0 - Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0 at server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM