加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Microsoft.Data.OData Breeze Server的版本不匹配 – 适用于Web

发布时间:2020-12-14 01:59:28 所属栏目:Windows 来源:网络整理
导读:Breeze Server – 适用于Nuget中的Web API 2版本1.4.8,安装Microsoft.Data.OData版本= 5.6.1,但引用版本5.6.0. 见下面的错误: 元数据查询失败:*;无法加载文件或程序集“Microsoft.Data.OData,Version = 5.6.0.0,Culture = neutral,PublicKeyToken = 31bf38
Breeze Server – 适用于Nuget中的Web API 2版本1.4.8,安装Microsoft.Data.OData版本= 5.6.1,但引用版本5.6.0.

见下面的错误:

元数据查询失败:*;无法加载文件或程序集“Microsoft.Data.OData,Version = 5.6.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配. (HRESULT异常:0x80131040)

解决方法

确保更正正确的程序集版本控制(如果是Web项目,则为web.config):

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.1.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Spatial" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.1.0" />
  </dependentAssembly>
</assemblyBinding>

然后在Data项目的app.config文件中,注释掉< entityFramework>部分:

<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer" />
    </providers>
  </entityFramework>

然后,如果您还没有,请添加以下配置部分:

<configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,EntityFramework,Version=6.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

最后,在您的XxDbContext类中,添加/修改您的静态构造函数:

static XxDbContext()
{
   var type1 = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
}

这些步骤解决了我的问题.祝好运.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读