Mac OS X and MySql Connector Issue

I downloaded mysql-connector-net-6.4.3-noinstall.zip, extracted and renamed mysql.data.dll to MySql.Data.dll:

$ cd v2/ $ ls mysql.data.cf.dll mysql.data.dll mysql.data.entity.dll mysql.visualstudio.dll mysql.web.dll $ mv mysql.data.dll MySql.Data.dll $ sudo gacutil /i MySql.Data.dll Password: Installed MySql.Data.dll into the gac (/Library/Frameworks/Mono.framework/Versions/2.10.4/lib/mono/gac) 

I than create a symbolic link in /Library/Frameworks/Mono.framework/Versions/2.10.4/lib/mono/2.0 on MySql.Data.dll:

 $ sudo ln -s ../gac/MySql.Data/6.4.3.0__c5687fc88969c44d/MySql.Data.dll MySql.Data.dll 

And create the package configuration file in /Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig so that I can reference the package from MonoDevelop:

 Name: MySql.Data Description: MySql.Data Version: 6.4.3.0 Libs: -r:/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/2.0/MySql.Data.dll 

Then I create a new console project, add a link to MySql.Data and build. The compiler crashes with the following exception:

 Unhandled Exception: System.IO.FileLoadException: The assembly name is invalid. at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0 at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () [0x00000] in <filename unknown>:0 at Mono.CSharp.MetadataImporter.GetAssemblyDefinition (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0 at Mono.CSharp.ReflectionImporter.ImportAssembly (System.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 at Mono.CSharp.DynamicLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileLoadException: The assembly name is invalid. at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0 at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () [0x00000] in <filename unknown>:0 at Mono.CSharp.MetadataImporter.GetAssemblyDefinition (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0 at Mono.CSharp.ReflectionImporter.ImportAssembly (System.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 at Mono.CSharp.DynamicLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 

I also tried to access the assembly directly with the same result.

Any tips?

I can set up my project on the .NET Framework v2.0 and build OK with gmcs, but not .NET 3.5 or 4.0 with dmcs.

+4
source share
2 answers

Update : I updated to version 2.10.5. I was able to download version 6.4.4.0 of the MySql connector for .NET / Mono. It seems to be working now.

I modified mcs to show the value of AssemblyName when loading via "-r" at compile time. In this case, I use the connector version 6.3.7.0 and mono version 2.10.4.

 mcs Main.cs -r:System.Data.dll -r:/usr/lib/mono/4.0/MySqlData.dll Unhandled Exception: System.IO.FileLoadException: The assembly name is invalid: MySql.Data.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1 at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0 at IKVM.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0 at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () [0x00000] in <filename unknown>:0 is invalid: MySql.Data.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1 mcs Main.cs -r:System.Data.dll -r:/usr/lib/mono/4.0/MySqlData.dll Unhandled Exception: System.IO.FileLoadException: The assembly name is invalid: MySql.Data.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d973bda91f71752c78294126974a41a08643168271f65fc0fb3cd45f658da01fbca75ac74067d18e7afbf1467d7a519ce0248b13719717281bb4ddd4ecd71a580dfe0912dfc3690b1d24c7e1975bf7eed90e4ab14e10501eedf763bff8ac204f955c9c15c2cf4ebf6563d8320b6ea8d1ea3807623141f4b81ae30a6c886b3ee1 at System.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0 at IKVM.Reflection.AssemblyName..ctor (System.String assemblyName) [0x00000] in <filename unknown>:0 at Mono.CSharp.ImportedAssemblyDefinition.ReadAttributes () [0x00000] in <filename unknown>:0 

It looks like the name does not match ("MySql.Data" and "MySql.Data.Tests").

+3
source

Things to check: make sure the MySQL connector was not built with 32-bit or 64-bit set, I had this problem with other assemblies before. Secondly, check all the dependencies of MySQL.Data.dll itself. Unfortunately, Mono does not show what the assembly name was. He might be trying to load one of these dependencies.

0
source

Source: https://habr.com/ru/post/1368849/


All Articles