如何修復dotnet Core中的MySQL連接器出現“無法解析類型”錯誤

2020-02-17 c# mysql .net-core

我正在嘗試構建一個連接到我的mysql數據的dotnet Core應用程序。 對於dotnet框架(在Windows上)和dotNetCore(在Windows上),這工作正常,但是當我從dotNet Core(在Linux上)嘗試時,出現錯誤消息:

System.TypeLoadException:無法解析來自typeref的令牌010000fd的類型(程序集“ System.Security.Permissions,版本為4.0.2.0,區域性為中性,PublicKeyToken = cc7b13ffcd2ddd51”中的預期類“ System.Security.PermissionSet”) 在MySql.Data.MySqlClient.MySqlConnection.Open()

我的csproj文件包含以下內容:

  <ItemGroup>
<PackageReference Include="AWSSDK.Kinesis" Version="3.3.100.38" />
<PackageReference Include="AWSSDK.Lambda" Version="3.3.19.24" />
<PackageReference Include="AWSSDK.S3" Version="3.3.3" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.3.3.26" />
<PackageReference Include="AWSSDK.SQS" Version="3.3.3.62" />
<PackageReference Include="CoreCLR-NCalc" Version="2.2.51" />
<PackageReference Include="Disruptor" Version="3.6.1" />
<PackageReference Include="ExcelDna.Integration" Version="0.34.6" />
<PackageReference Include="MathNet.Numerics" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.10.0" />
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" />
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
<PackageReference Include="Mono.Data.Sqlite" Version="1.0.61" />
<PackageReference Include="MySql.Data" Version="8.0.19" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Parquet.Net" Version="3.2.4" />
<PackageReference Include="protobuf-net" Version="2.4.0" />
<PackageReference Include="System.CodeDom" Version="4.7.0" />
<PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
<PackageReference Include="System.Data.SQLite" Version="1.0.112" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="unofficial.sevenziplib.codeplex" Version="9.13.5" />
 </ItemGroup>

我該如何解決?

Answers

在我的.net核心項目中,我使用Pomelo.EntityFrameworkCore.MySql包與MySQL連接,這對我來說很好用。

您可能想檢查一下當前插件是否仍然存在問題。

https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql

Related