实体框架核心异常“System.Runtime.Versioning.BinaryCompatibility”

时间:2017-04-12 08:03:03

标签: c# entity-framework debian .net-core

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

  • 控制台应用
  • 数据库访问dll

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

当我启动我的控制台应用程序时,Entity Framework Core会抛出异常。

异常消息:

  

'System.Runtime.Versioning.BinaryCompatibility'的类型初始值设定项引发了异常。

内部异常消息:

  

无法加载文件或程序集'System.Runtime.InteropServices,Version = 4.1.1.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'。定位的程序集的m anifest定义与程序集引用不匹配。 (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-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>

我的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.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>

我尝试使用不同的运行时和SDK,但问题仍然存在。

你知道问题是什么吗?

1 个答案:

答案 0 :(得分:0)

找到了解决方案。

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

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

来自我的应用项目配置。

它现在有效。