vb.net 无法导入 MySql.Data.MySqlClient
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15587233/
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
unable to import MySql.Data.MySqlClient
提问by kasperB
I have created a website that uses a MySQLdatabase, but when i put it online, it doesn't work anymore. in my class connection.vbthat i use for my connection to my database i get the following warning:
我创建了一个使用MySQL数据库的网站,但是当我把它放到网上时,它不再工作了。在我connection.vb用于连接到我的数据库的类中,我收到以下警告:
Namespace or type specified in the Imports 'MySql.Data.MySqlClient' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
导入“MySql.Data.MySqlClient”中指定的命名空间或类型不包含任何公共成员或无法找到。确保命名空间或类型已定义并且至少包含一个公共成员。确保导入的元素名称不使用任何别名。
and it says that the type mysqlconnectionis not defined.
并表示mysqlconnection未定义类型。
this is my code:
这是我的代码:
Imports Microsoft.VisualBasic
Imports MySql.Data.MySqlClient
Public Class connection
Public Shared cn As New MySqlConnection(ConfigurationManager.ConnectionStrings("cnDatabase").ConnectionString)
End Class
If i do the same imports statement in an other vbfile such as e.g index.aspx.vb it gives me no error
如果我在其他vb文件(例如 index.aspx.vb)中执行相同的导入语句,它不会给我任何错误
Does anybody know what is wrong?
有人知道出了什么问题吗?
Thanks in advance.
提前致谢。
回答by Arnaud
回答by Sumit Kharbikar
try this, You have to remove old reference of that file add new reference as when we are copying file from one machine to another machine the reference for assembly is some time also taking from copied machine.
试试这个,您必须删除该文件的旧参考添加新参考,因为当我们将文件从一台机器复制到另一台机器时,组装参考也需要从复制的机器上获取一段时间。
so you can check this,
所以你可以检查这个,
- Select ->Properties of project
- Go to the reference 3.check the reference of assembly exists or not
- if path showing "The system cannot find the reference specified"
- download latest MySql connector/Net from https://dev.mysql.com/downloads/connector/net/for .Net Mono
- remove the reference and add the new reference from visual studio-Proerties-reference
- 选择 -> 项目属性
- 转到参考 3.检查程序集的参考是否存在
- 如果路径显示“系统找不到指定的引用”
- 从https://dev.mysql.com/downloads/connector/net/为 .Net Mono下载最新的 MySql 连接器/Net
- 删除引用并从 Visual Studio-Proerties-reference 添加新引用
回答by Edgar Conrado
Try this,
尝试这个,
- Double click in My Project.
- In the tab "References" remove MySQL.Data.
- Try to re-install it again.
- 双击我的项目。
- 在“参考”选项卡中删除 MySQL.Data。
- 尝试重新安装它。

