我在 GAC 中添加了 System.Web.Mvc v4.0.0.0,所以我通过 nuget 使用“Install-Package Microsoft.AspNet.Mvc -Version 5.2.3”手动安装了 Mvc。
我现在已经安装了 System.Web.Mvc v5.2.3.0,
和 GAC 中的 System.Web.Mvc v4.0.0.0
我在 Web.config 中有这个:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
我构建并运行该项目,但出现下一个错误:
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.
但是我已经配置并添加了 MVC v5.2.3.0 包。为什么会出现这个错误?
已解决
取消引用 System.Web.Mvc
引用 -> 右键单击 -> 管理 NuGet 包... -> 卸载 MVC -> 现在“安装”。
最佳答案
您看到的程序集来自 GAC .这并不一定意味着您在项目中使用它。如果要查看项目中安装的实际包,请右键单击该项目并单击“管理 NuGet 包”。
在“添加引用”屏幕上取消选中版本 4,然后使用包管理器控制台通过 NuGet 安装特定版本。确保您选择了正确的项目来安装包。
关于asp.net - 错误的 System.Web.Mvc 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29882493/