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

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

问题描述

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

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

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

我按照说明安装了 Microsoft DotNet 网站上的运行时.

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

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

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

异常信息:

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

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

内部异常消息:

无法加载文件或程序集System.Runtime.InteropServices,版本=4.1.1.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a".定位的程序集的清单定义与程序集引用不匹配.(来自 HRESULT 的异常:0x80131040)

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.CoreProject.Core.csproj" />
    <ProjectReference Include="..Project.DatabaseProject.Database.csproj" />
  </ItemGroup>

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

</Project>

还有我的 Project.Database 配置:

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>

我尝试了不同的运行时和 SDK,但仍然是同样的问题.

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

你知道问题出在哪里吗?

Do you know what the problem is?

推荐答案

找到解决方案.

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

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.

现在可以使用了.

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

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