我正在尝试使用连接到MySQL实例的Linq2Db生成数据库映射。但是,当我尝试在Visual Studio中运行模板文件时,它会导致SSL连接错误以及“文件未找到”异常,表明无法找到BouncyCastle.Crypto。我已经尝试过多个项目,但一直收到此错误。它正在另一个项目中正常工作。但是现在,它只是不想合作。

Error       Running transformation:
 MySql.Data.MySqlClient.MySqlException (0x80004005): SSL Connection
error. ---> System.AggregateException: One or more errors occurred.
---> System.IO.FileNotFoundException: Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942' or one of its dependencies. The system cannot find the file specified.


   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString)
---> (Inner Exception #0) System.IO.FileNotFoundException: Could not load file or assembly 'BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942' or one of its dependencies. The system cannot find the file specified.
File name: 'BouncyCastle.Crypto, Version=1.8.3.0, Culture=neutral, PublicKeyToken=0e99375e54769942'

at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
   at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
<---

   at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString)
   at MySql.Data.MySqlClient.NativeDriver.Open()
   at MySql.Data.MySqlClient.Driver.Open()
   at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
   at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
   at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
   at MySql.Data.MySqlClient.MySqlPool.GetConnection()
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at LinqToDB.Async.AsyncDbConnection.Open()
   at LinqToDB.Data.DataConnection.EnsureConnection()
   at LinqToDB.SchemaProvider.SchemaProviderBase.GetSchema(DataConnection dataConnection, GetSchemaOptions options)
   at Microsoft.VisualStudio.TextTemplatingD2824CB3C7AE82E55C24545FCC5C772FAA5FFC60036C454D8924BF14A567283BB1BB669E693FBF53B1FDEE885877A654028D4F18DB00863F5E4E9F61A1BFECC3.GeneratedTextTransformation.LoadServerMetadata(DataConnection dataConnection) in C:\Users\joshu\.nuget\packages\linq2db.mysql\2.7.4\build\..\contentFiles\any\any\LinqToDB.Templates\DataModel.ttinclude:line 103
   at Microsoft.VisualStudio.TextTemplatingD2824CB3C7AE82E55C24545FCC5C772FAA5FFC60036C454D8924BF14A567283BB1BB669E693FBF53B1FDEE885877A654028D4F18DB00863F5E4E9F61A1BFECC3.GeneratedTextTransformation.LoadMetadata(DataConnection dataConnection) in C:\Users\joshu\.nuget\packages\linq2db.mysql\2.7.4\build\..\contentFiles\any\any\LinqToDB.Templates\DataModel.ttinclude:line 415
   at Microsoft.VisualStudio.TextTemplatingD2824CB3C7AE82E55C24545FCC5C772FAA5FFC60036C454D8924BF14A567283BB1BB669E693FBF53B1FDEE885877A654028D4F18DB00863F5E4E9F61A1BFECC3.GeneratedTextTransformation.LoadMySqlMetadata(String server, String database, String uid, String password, Int32 port) in C:\Users\joshu\.nuget\packages\linq2db.mysql\2.7.4\build\..\contentFiles\any\any\LinqToDB.Templates\LinqToDB.MySql.ttinclude:line 28
   at Microsoft.VisualStudio.TextTemplatingD2824CB3C7AE82E55C24545FCC5C772FAA5FFC60036C454D8924BF14A567283BB1BB669E693FBF53B1FDEE885877A654028D4F18DB00863F5E4E9F61A1BFECC3.GeneratedTextTransformation.TransformText() in C:\Users\joshu\Projects\HSM.API\HSM.Data\DataModels\MySqlDb.tt:line 41       C:\Users\joshu\.nuget\packages\linq2db.mysql\2.7.4\build\..\contentFiles\any\any\LinqToDB.Templates\DataModel.ttinclude 103

最佳答案

您在我们的程序包中发现了一个错误。在此处填写https://github.com/linq2db/linq2db/issues/1772。您可以尝试将缺少的依赖项(充气城堡)添加到packages \ linq2db.MySqlConnector.2.7.4 \ tools \中作为解决方法

07-24 09:33