简体   繁体   English

无法加载文件或程序集'WebMatrix.Data`

[英]Could not load file or assembly 'WebMatrix.Data`

I updated MVC4 to MVC5. 我将MVC4更新为MVC5。 When you run the application I got an error that I don't have WebMatrix.Data . 当您运行应用程序时,我收到一个错误,我没有WebMatrix.Data I installed it PM> Install-Package WebMatrix.Data . 我安装了PM> Install-Package WebMatrix.Data Now when you start getting in the browser: 现在,当您开始进入浏览器时:

Could not load file or assembly 'WebMatrix.Data, Version = 3.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' or one of its dependencies. 无法加载文件或程序集'WebMatrix.Data,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 Located assembly's manifest definition does not match the assembly reference. 位于程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT异常:0x80131040)

Anyone know how to fix this? 有人知道怎么修这个东西吗?

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.`

Piece of code Web.config 一段代码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>

Go into: Tools > NuGet Package Manager > Package Manager Console 进入: Tools > NuGet Package Manager > Package Manager Console

And run the following command: 并运行以下命令:

PM> Install-Package Microsoft.AspNet.WebPages.Data

This is what worked for me. 这对我有用。 Took weeks to figure it out. 花了好几个星期才搞清楚。

Make sure your target framework to what you want it to be (I had 4.6.1 ). 确保您的目标框架符合您的要求(我有4.6.1 )。

Go into: Tools > NuGet Package Manager > Package Manager Console and do the following commands. 进入: 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

Hope this helps anyone that tried the other solutions with no luck. 希望这有助于任何尝试其他解决方案而没有运气的人。

This is actually a legacy library. 这实际上是一个遗留库。 You should instead install Microsoft.AspNet.WebPages.Data if you are upgrading from MVC 4 to 5. 如果要从MVC 4升级到5,则应该安装Microsoft.AspNet.WebPages.Data。

PM> Install-Package Microsoft.AspNet.WebPages.Data

这也有效

Update-Package Microsoft.AspNet.WebPages.Data

from your package manager console I can see that your project has Successfully added 'WebMatrix.Data 2.0.30506.0' to xxx.` 从您的包管理器控制台我可以看到您的项目已成功将“WebMatrix.Data 2.0.30506.0”添加到xxx。

So get your web.config in sync with WebMatrix.Data 2.0.30506.0 因此,请将您的web.config与WebMatrix.Data 2.0.30506.0同步

安装MVC 4(不是运行时但是完整版)为我修复了它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM