-
Notifications
You must be signed in to change notification settings - Fork 345
-
Recently started trying to use MySqlConnector with below setup:
- MySqlConnector
- Windows 11 Pro
- Powershell (trying Windows PowerShell but willing to use Powershell 7.x if viable)
- MySqlConnector.Authentication.Ed25519 plugin
- MariaDB
I'm stumped as the connection open fails due to not being able to load System.Buffers, but it's already loaded with the version and Public Key Token it's complaining about from what I can tell.
Any suggestions on how to get around this issue is appreciated.
$maedir="$env:systemdrive\scripts\nugets\MySqlConnector.Authentication.Ed25519"
if((test-path -path $maedir) -eq $false){
nuget install 'MySqlConnector.Authentication.Ed25519' -outputdirectory $maedir
}
$srcdir="$env:systemdrive\scripts\nugets\System.Runtime.CompilerServices.Unsafe.4.5.3"
if((test-path -path $srcdir) -eq $false){
nuget install 'System.Runtime.CompilerServices.Unsafe' -outputdirectory $srcdir -version 4.5.3
}
$domainSetup = New-Object System.AppDomainSetup
$domainSetup.ApplicationBase = [System.IO.Directory]::GetCurrentDirectory()
$newDomain = [System.AppDomain]::CreateDomain("NewAppDomain", $null, $domainSetup)
Add-Type -Path "$env:systemdrive\scripts\nugets\MySqlConnector.Authentication.Ed25519\System.Memory.4.5.5\lib\net461\System.Memory.dll"
add-type -path "$env:systemdrive\scripts\nugets\MySqlConnector.Authentication.Ed25519\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll"
$mscngci=Get-ChildItem -path "$systemdrive\scripts\nugets\MySqlConnector.Authentication.Ed25519\mysqlconnector.*" | where-object {$_.Name -match 'mysqlconnector\.[0-9]'}
$mscnpath=-join($mscngci.tostring(),'\lib\net462\MySqlConnector.dll')
add-type -path $mscnpath
$ed2gci=Get-ChildItem -path "$systemdrive\scripts\nugets\mysqlconnector.authentication.ed25519\MySqlConnector.Authentication.Ed25519.*"
$ed2path=-join($ed2gci.tostring(),'\lib\net462\MySqlConnector.Authentication.Ed25519.dll')
add-type -path $ed2path
$sddsgci=Get-ChildItem -path "$systemdrive\scripts\nugets\mysqlconnector.authentication.ed25519\System.Diagnostics.DiagnosticSource.*"
$sddspath=-join($sddsgci.tostring(),'\lib\net462\System.Diagnostics.DiagnosticSource.dll')
add-type -path $sddspath
$srcugci=Get-ChildItem -path "$systemdrive\scripts\nugets\System.Runtime.CompilerServices.Unsafe.4.5.3\System.Runtime.CompilerServices.Unsafe.*"
$srcupath=-join($srcugci.tostring(),'\lib\net461\System.Runtime.CompilerServices.Unsafe.dll')
add-type -path $srcupath
$sbgci=Get-ChildItem -path "$systemdrive\scripts\nugets\mysqlconnector.authentication.ed25519\System.Buffers.*"
$sbpath=-join($sbgci.tostring(),'\lib\net461\System.Buffers.dll')
add-type -path $sbpath
[MySqlConnector.Authentication.Ed25519.Ed25519AuthenticationPlugin]::Install()
$connectionString="Server=localhost;Uid=root;Pwd=PASSWORD;Port=3306;ConnectionTimeout=31536000;SslMode=None;"
$connection=New-Object MySqlConnector.MySqlConnection($connectionString)
try {
$connection.Open()
}catch{
$_.Exception | Format-List * -Force
}
ErrorRecord : Exception calling "Open" with "0" argument(s): "The type initializer for
'MySqlConnector.Core.ConnectionPool' threw an exception."
WasThrownFromThrowStatement : False
Message : Exception calling "Open" with "0" argument(s): "The type initializer for
'MySqlConnector.Core.ConnectionPool' threw an exception."
Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException : System.TypeInitializationException: The type initializer for
'MySqlConnector.Core.ConnectionPool' threw an exception. --->
System.IO.FileNotFoundException: Could not load file or assembly 'System.Buffers,
Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its
dependencies. The system cannot find the file specified.
at System.Text.ValueStringBuilder.Dispose()
at System.Text.ValueStringBuilder.ToString()
at Microsoft.Extensions.Logging.LogValuesFormatter..ctor(String format)
at Microsoft.Extensions.Logging.LoggerMessage.CreateLogValuesFormatter(String
formatString, Int32 expectedNamedParameterCount)
at Microsoft.Extensions.Logging.LoggerMessage.Define[T1,T2](LogLevel logLevel,
EventId eventId, String formatString, LogDefineOptions options)
at Microsoft.Extensions.Logging.LoggerMessage.Define[T1,T2](LogLevel logLevel,
EventId eventId, String formatString)
at MySqlConnector.Core.ConnectionPool..cctor()
--- End of inner exception stack trace ---
at MySqlConnector.Core.ConnectionPool.GetPool(String connectionString,
MySqlConnectorLoggingConfiguration loggingConfiguration, Boolean createIfNotFound)
at MySqlConnector.MySqlConnection.<OpenAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at MySqlConnector.MySqlConnection.Open()
at CallSite.Target(Closure , CallSite , Object )
TargetSite : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext,
System.Exception)
StackTrace : at
System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
funcContext, Exception exception)
at
System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interp
retedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Interp
retedFrame frame)
HelpLink :
Source : System.Management.Automation
HResult : -2146233087
[System.AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -eq 'System.Buffers' } | ForEach-Object {
$name = $_.GetName()
$version = $name.Version
$publicKeyToken = [BitConverter]::ToString($name.GetPublicKeyToken()) -replace '-'
[PSCustomObject]@{
Name = $name.Name
Version = $version
PublicKeyToken = $publicKeyToken
}
}
Name Version PublicKeyToken
---- ------- --------------
System.Buffers 4.0.3.0 CC7B13FFCD2DDD51
$psversiontable
Name Value
---- -----
PSVersion 5.1.26100.2161
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.2161
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
systeminfo | where-object {$_ -match '^OS Name'}
OS Name: Microsoft Windows 11 Pro
$connection
ConnectionString : Server=localhost;Uid=root;Pwd=PASSWORD;Port=3306;ConnectionTimeout=31536000;SslMode=None;
Database :
State : Connecting
DataSource : localhost
ServerVersion :
ServerThread :
ProvideClientCertificatesCallback :
ProvidePasswordCallback :
RemoteCertificateValidationCallback :
ConnectionTimeout : 31536000
CanCreateBatch : True
Site :
Container :
SELECT VERSION();
+----------------+
| VERSION() |
+----------------+
| 11.6.2-MariaDB |
+----------------+
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment