简体   繁体   中英

Entity Framework Core Exception “System.Runtime.Versioning.BinaryCompatibility”

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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