无法加载文件或程序集 'mysql.data, version=6.9.5.0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28183792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:17:23  来源:igfitidea点击:

could not load file or assembly 'mysql.data, version=6.9.5.0

mysql.netvb.netdll

提问by Ryan Smith

I'm having a issue with a Visual Basic 2013 program I made (in vb.net) and the issue is with MySQL.data.dll, I've tried changing copy local to true in the GAC, I've tried upgrading my MySQL.data.dll to the most recent version but whatever I do it only works if the MySQL.data.dll folder is in the same folder as the executable when running it.

我的 Visual Basic 2013 程序有问题(在 vb.net 中),问题出在 MySQL.data.dll,我尝试在 GAC 中将 copy local 更改为 true,我尝试升级我的MySQL.data.dll 到最新版本,但无论我做什么,只有当 MySQL.data.dll 文件夹在运行时与可执行文件位于同一文件夹中时才有效。

(Do note that this error only occurs on other machines, not my machine)

请注意,此错误仅发生在其他机器上,而不是我的机器上

This is the error exactly:

这正是错误:

[Could not load file or assembly 'MySql.data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.]

[无法加载文件或程序集 'MySql.data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' 或其依赖项之一。该系统找不到指定的文件。]

Please help, I don't want to have my users have to put MySQL.data.dll in a file with the exe just to be able to run it (for obvious reasons.)

请帮忙,我不想让我的用户必须将 MySQL.data.dll 放在一个带有 exe 的文件中才能运行它(出于显而易见的原因。)

回答by Mick

Check the version of the MySQL assembly against the versions appearing in the compiler output.

根据编译器输出中出现的版本检查 MySQL 程序集的版本。

Do not use the error list look at the Output window and select Build from the drop down and look for errors.

不要使用错误列表查看输出窗口并从下拉列表中选择构建并查找错误。

The most probable cause is your application is linked to specific (possibly multiple) versions of MySQL, and there is a conflict on the specific version of MySQL referenced. You might also want to change the specific version property of the assembly reference...

最可能的原因是您的应用程序链接到特定(可能是多个)版本的 MySQL,并且引用的特定 MySQL 版本存在冲突。您可能还想更改程序集引用的特定版本属性...

How exactly does the "Specific Version" property of an assembly reference work in Visual Studio?

程序集引用的“特定版本”属性在 Visual Studio 中究竟是如何工作的?

asp server error ' Could not load file or assembly ' but the assembly is definitely there.

asp 服务器错误“无法加载文件或程序集”,但程序集肯定存在。

It's pretty simple. You need to make sure the reference to the assembly is correct. I'd avoid installing MySQL into the GAC. Don't install the MSI, if you have uninstall it, then download the zip archive

这很简单。您需要确保对程序集的引用是正确的。我会避免将 MySQL 安装到 GAC 中。不要安装 MSI,如果你已经卸载它,然后下载 zip 存档

mysql-connector-net-6.9.5-noinstall.zip

mysql-connector-net-6.9.5-noinstall.zip

Extract the files to a folder reference those assemblies in your solution. If you're using source control check the folder containing the MySQL assemblies into source control, with the rest of the solution.

将文件解压缩到一个文件夹,引用解决方案中的这些程序集。如果您使用源代码管理,请将包含 MySQL 程序集的文件夹与解决方案的其余部分一起检查到源代码管理中。

If you have more than one assembly referencing MySQL you should check that they are all referencing the same version, from the same location and/or have the "Specific Version" property set to false and "Copy Local" set to true.

如果您有多个引用 MySQL 的程序集,您应该检查它们是否都从相同的位置引用相同的版本和/或将“特定版本”属性设置为 false 并将“复制本地”设置为 true。