【问题标题】:Entity Framework Core Exception "System.Runtime.Versioning.BinaryCompatibility"实体框架核心异常“System.Runtime.Versioning.BinaryCompatibility”
【发布时间】:2017-04-13 17:37:12
【问题描述】:

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

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

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

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

异常消息:

“System.Runtime.Versioning.BinaryCompatibility”的类型初始化程序引发了异常。

内部异常消息:

无法加载文件或程序集“System.Runtime.InteropServices,版本=4.1.1.0,文化=中性,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-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,但仍然是同样的问题。

你知道问题出在哪里吗?

【问题讨论】:

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


    【解决方案1】:

    找到了解决办法。

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

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

    来自我的应用项目配置。

    现在可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-16
      • 2021-07-14
      • 1970-01-01
      • 1970-01-01
      • 2017-04-03
      • 2020-05-10
      相关资源
      最近更新 更多