Mac OS X Mono 和 MySql 连接器问题
我下载了 mysql-connector-net-6.4.3-noinstall.zip,解压缩并将 mysql.data.dll 重命名为 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)
然后在 /Library/Frameworks/Mono.framework/Versions/2.10 中创建符号链接.4/lib/mono/2.0 到 MySql.Data.dll:
$ sudo ln -s ../gac/MySql.Data/6.4.3.0__c5687fc88969c44d/MySql.Data.dll MySql.Data.dll
并在中创建包配置文件/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig,以便我可以引用 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
然后我创建一个新的控制台项目,添加对 MySql.Data 的引用并构建。编译器失败,但出现以下异常:
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
我还尝试直接引用程序集,结果相同。
有什么建议吗?
我可以将我的项目定位到 .NET Framework v2.0 并使用 gmcs 构建正常,但不能使用 dmcs 构建 .NET 3.5 或 4.0。
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 to MySql.Data.dll:
$ sudo ln -s ../gac/MySql.Data/6.4.3.0__c5687fc88969c44d/MySql.Data.dll MySql.Data.dll
And create a package configuration file in /Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig so that I can reference 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 reference to MySql.Data and build. Compiler fails 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 referencing the assembly directly with the same result.
Any advice?
I can target my project to .NET Framework v2.0 and build OK with gmcs, but not .NET 3.5 or 4.0 with dmcs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新:我升级到了 mono 2.10.5。我能够加载 .NET/Mono 的 MySql 连接器版本 6.4.4.0。看来现在正在工作。
我修改了 mcs,以在编译期间通过“-r”加载时显示 AssemblyName 值。在本例中,我使用连接器版本 6.3.7.0 和单声道版本 2.10.4。
名称似乎不匹配(“MySql.Data”与“MySql.Data.Tests”)。
Update: I upgraded to mono 2.10.5. I was able to load the version 6.4.4.0 of the MySql connector for .NET/Mono. Seems to be working now.
I modified the mcs to show the AssemblyName value when loaded via "-r" during compilation. In this case I'm using connector version 6.3.7.0 and mono version 2.10.4.
It appears that name doesn't match ("MySql.Data" vs. "MySql.Data.Tests").
要检查的事项:确保 MySQL 连接器不是使用 32 位或 64 位集构建的,我之前在其他程序集上也遇到过这个问题。其次,检查MySQL.Data.dll本身的所有依赖项。不幸的是 Mono 不显示程序集名称是什么。它可能正在尝试加载它的依赖项之一。
Things to check: Ensure that the MySQL connector wasn't built with 32-bit or 64-bit set, I've had this problem with other Assemblies before. Second, check all the dependencies of the MySQL.Data.dll itself. It is unfortunate Mono does't display WHAT the assembly name was. It could of been trying to load one of it's dependencies.