Jeremy Jeremy - 2 years ago 207
MySQL Question

Error 0x80131047 loading MySQL Connector DLL

PowerShell has just been opened sourced (v6.0.0-alpha.10), and I'm
trying to get it to connect to a MySQL instance from OS X.

Oracle seems to suggest (if I'm reading it correctly) that they have a
.Net Core connector
I ran the install like this:

Install-Package MySql.ConnectorNET.Entity -Destination /MySQL

and the output looked good:

Name                       Version Source Summary                

---- ------- ------ -------
MySql.ConnectorNET.Data nugget ADO.Net driver for MySQL
MySql.ConnectorNET.Entity nugget MySql Connector/NET for Entity Framework 6

When I try loading the assembly like this:


I get the following error (note that I pass the path in with a

Exception calling "Load" with "1" argument(s): "Could not load
file or assembly
Culture=neutral, PublicKeyToken=null'. The given assembly name or
codebase was invalid. (Exception from HRESULT: 0x80131047)" At
/development/scripts/test.ps1:28 char:1
+ [System.Reflection.Assembly]::Load("$dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException

Any ideas on a workaround / fix? I realize that PowerShell is still in


I was able to install the MySQL provider using these two commands:

Register-PackageSource -Name -ProviderName NuGet -Location
Install-Package MySql.Data.EntityFrameworkCore -Destination /Volumes/Main/libraries/MySQL/ -AllowPrereleaseVersions

I tried registering all the assemblies I could think of:


But, when trying to create a new MySql object, it still bombs out with
New-Object : Cannot find type [MySql.Data.MySqlClient]:
verify that the assembly containing this type is loaded.


posted down below

Answer Source


So, it turns out I was on the (mostly) right track. All of the DLLs need to be loaded. Make life easier by copying them into their own directory, and then load them by iterating over each one:

copy the DLLs to a new location

Get-ChildItem "/Volumes/Main/libraries/mysql/*/lib/netstandard1.*/*.dll" | Copy-Item -Destination "/Volumes/Main/libraries/NEW_mysql" -Force

load all required DLLs

Get-ChildItem "/Volumes/Main/libraries/NEW_mysql" | ForEach-Object {
$path = "/Volumes/Main/libraries/NEW_mysql/" + $_.Name
Add-Type -Path $path -PassThru | Out-Null
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download