实体框架核心异常“System.Runtime.Versioning.BinaryCompatibility” [英] Entity Framework Core Exception "System.Runtime.Versioning.BinaryCompatibility"

查看:255
本文介绍了实体框架核心异常“System.Runtime.Versioning.BinaryCompatibility”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的debian 8服务器上运行我的dotnet核心应用程序。我的应用程序分为两部分。




  • 控制台应用程序

  • 数据库访问dll



我按照说明在Microsoft DotNet网站上安装运行时。



我启动了我的控制台应用程序,实体框架核心引发了一个例外。



异常消息:


'System.Runtime.Versioning.BinaryCompatibility'的类型初始化器抛出异常。


内部异常消息:无法加载文件或程序集'System.Runtime.InteropServices,Version = 4.1.1.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'。定位的组件的最佳定义与组合参考不匹配。 (HRESULT的异常:0x80131040)


这是我的应用程序的配置方式:

 < Project Sdk =Microsoft.NET.Sdk> 

< PropertyGroup>
< AssemblyTitle> Project.Login< / AssemblyTitle>
< TargetFramework> netcoreapp1.1< / TargetFramework>
< AssemblyName> Project.Login< / AssemblyName>
< OutputType> Exe< / OutputType>
< PackageId> Project.Login< / PackageId>
< RuntimeIdentifiers> win10-x64; win7-x64; osx.10.10-x64; ubuntu.14.04-x64; ubuntu.14.10-x64; ubuntu.15.04-x64; ubuntu.15.10-x64; ubuntu.16.04- 64; ubuntu.16.10-64; centos.7-64; debian.8-64; fedora.23-64; fedora.24-64< / RuntimeIdentifiers>
< PackageTargetFallback> $(PackageTargetFallback); dnxcore50< / PackageTargetFallback>
< RuntimeFrameworkVersion> 1.0.4< / RuntimeFrameworkVersion>
< GenerateAssemblyConfigurationAttribute> false< / GenerateAssemblyConfigurationAttribute>
< GenerateAssemblyCompanyAttribute> false< / GenerateAssemblyCompanyAttribute>
< GenerateAssemblyProductAttribute> false< / GenerateAssemblyProductAttribute>
< / PropertyGroup>

< ItemGroup>
< ProjectReference Include =.. \Project.Core\Project.Core.csproj/>
< ProjectReference Include =.. \Project.Database\Project.Database.csproj/>
< / ItemGroup>

< ItemGroup>
< PackageReference Include =Ether.NetworkVersion =1.1.7/>
< / ItemGroup>

< / Project>

我的Project.Database配置:

 < Project Sdk =Microsoft.NET.Sdk> 

< PropertyGroup>
< TargetFramework> netstandard1.6< / TargetFramework>
< AssemblyName> Project.Database< / AssemblyName>
< PackageId> Project.Database< / PackageId>
< NetStandardImplicitPackageVersion> 1.6.1< / NetStandardImplicitPackageVersion>
< PackageTargetFallback> $(PackageTargetFallback); dnxcore50< / PackageTargetFallback>
< GenerateAssemblyConfigurationAttribute> false< / GenerateAssemblyConfigurationAttribute>
< GenerateAssemblyCompanyAttribute> false< / GenerateAssemblyCompanyAttribute>
< GenerateAssemblyProductAttribute> false< / GenerateAssemblyProductAttribute>
< / PropertyGroup>

< ItemGroup>
< PackageReference Include =System.Text.Encoding.CodePagesVersion =4.3.0/>
< PackageReference Include =Pomelo.EntityFrameworkCore.MySqlVersion =1.1.0/>
< PackageReference Include =System.Reflection.TypeExtensionsVersion =4.3.0/>
< PackageReference Include =MySql.Data.EntityFrameworkCoreVersion =7.0.6-IR31/>
< / ItemGroup>

< / Project>

我尝试使用不同的运行时和SDK,仍然是同样的问题。



你知道问题是什么吗?

解决方案

找到解决方案。
$ b

我已将 Microsoft.EntityFrameworkCore 1.1包添加到我的 Project.Database 项目并删除 Pomelo.EntityFrameworkCore.MySql 并删除两行:

 < PackageTargetFallback> $(PackageTargetFallback); dnxcore50< / PackageTargetFallback> 
< RuntimeFrameworkVersion> 1.0.4< / RuntimeFrameworkVersion>

从我的应用程序项目配置。



现在可以使用。


I am trying to run my dotnet core application on my debian 8 server. My app is divided in two.

  • The console app
  • The database access dll

I followed the instruction to install the runtime on the Microsoft DotNet website.

When I start my console app, Entity Framework Core throws me an exception.

Exception Message:

The type initializer for 'System.Runtime.Versioning.BinaryCompatibility' threw an exception.

Inner Exception Message:

Could not load file or assembly 'System.Runtime.InteropServices, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's m anifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This is how my app is configured:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <AssemblyTitle>Project.Login</AssemblyTitle>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AssemblyName>Project.Login</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>Project.Login</PackageId>
    <RuntimeIdentifiers>win10-x64;win7-x64;osx.10.10-x64;ubuntu.14.04-x64;ubuntu.14.10-x64;ubuntu.15.04-x64;ubuntu.15.10-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;debian.8-x64;fedora.23-x64;fedora.24-x64</RuntimeIdentifiers>
    <PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
    <RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Project.Core\Project.Core.csproj" />
    <ProjectReference Include="..\Project.Database\Project.Database.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Ether.Network" Version="1.1.7" />
  </ItemGroup>

</Project>

And my Project.Database configuration :

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard1.6</TargetFramework>
    <AssemblyName>Project.Database</AssemblyName>
    <PackageId>Project.Database</PackageId>
    <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
    <PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Text.Encoding.CodePages" Version="4.3.0" />
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="1.1.0" />
    <PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.6-IR31" />
  </ItemGroup>

</Project>

I tried with differents runtimes and SDK and still the same issue.

Do you know what the problem is?

解决方案

Found the solution.

I've added the Microsoft.EntityFrameworkCore 1.1 package to my Project.Database project and deleted the Pomelo.EntityFrameworkCore.MySql and remove the two lines :

<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>

from my apps project configuration.

It now works.

这篇关于实体框架核心异常“System.Runtime.Versioning.BinaryCompatibility”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆