无法加载文件或程序集'WebMatrix.Data '
本文关键字:WebMatrix Data 程序集 加载 文件 | 更新日期: 2023-09-27 18:10:08
我将MVC4更新为MVC5。当你运行应用程序时,我得到一个错误,我没有WebMatrix.Data
。我安装了PM> Install-Package WebMatrix.Data
。现在,当你开始进入浏览器:
无法加载文件或程序集'WebMatrix '。数据,版本= 3.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35'或其之一依赖关系。定位程序集的清单定义不匹配程序集引用。(Exception from HRESULT: 0x80131040)
有人知道如何解决这个问题吗?
Package Manager Console Log
Attempting to resolve dependency 'Microsoft.AspNet.WebPages.Data (≥ 2.0.20710.0)'.
Installing 'WebMatrix.Data 2.0.30506.0'.
You are downloading WebMatrix.Data from Microsoft, the license agreement to which is available at http://www.microsoft.com/web/webpi/eula/aspnetcomponent_rtw_enu.htm. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'WebMatrix.Data 2.0.30506.0'.
Adding 'WebMatrix.Data 2.0.30506.0' to xxx.
Successfully added 'WebMatrix.Data 2.0.30506.0' to xxx.`
Web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.3.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNet.Identity.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.WebData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebMatrix.Data" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
进入:Tools > NuGet Package Manager > Package Manager Console
并执行以下命令:
PM> Install-Package Microsoft.AspNet.WebPages.Data
我就是这么做的。我花了好几个星期才弄明白。
确保你的目标框架是你想要的(我有4.6.1
)。
进入:Tools > NuGet Package Manager > Package Manager Console
,执行以下命令:
Uninstall-Package Microsoft.AspNet.WebHelpers
Uninstall-Package Microsoft.AspNet.WebPages.OAuth
Uninstall-Package Microsoft.AspNet.WebPages.WebData
Uninstall-Package Microsoft.AspNet.WebPages.Data
Install-Package Microsoft.AspNet.WebPages.Data
Install-Package Microsoft.AspNet.WebPages.WebData
Install-Package Microsoft.AspNet.WebPages.OAuth
Install-Package Microsoft.AspNet.WebHelpers
希望这篇文章能帮助到那些尝试过其他解决方案但运气不好的人。
这实际上是一个遗留库。如果你要从MVC 4升级到MVC 5,你应该安装microsoft . asp.net . webpages . data。
PM> Install-Package Microsoft.AspNet.WebPages.Data
也可以
Update-Package Microsoft.AspNet.WebPages.Data
从你的包管理器控制台我可以看到你的项目已经成功地添加了'WebMatrix。数据2.0.30506.0' to xxx. '
所以带上你的网。配置与WebMatrix同步。数据2.0.30506.0
安装MVC 4(不是运行时,但完整版本)修复它为我。