unable to import MySql.Data.MySqlClient

有些话、适合烂在心里 提交于 2019-12-25 01:47:29

问题


I have created a website that uses a MySQL database, but when i put it online, it doesn't work anymore. in my class connection.vb that i use for my connection to my database i get the following warning:

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.

and it says that the type mysqlconnection is not defined.

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 vb file such as e.g index.aspx.vb it gives me no error

Does anybody know what is wrong?

Thanks in advance.


回答1:


Make sure to embed the dll files for Mysql. Check the dependencies of your project, resources paths must be different from your local configuration. I think you can find what you're looking for on this website




回答2:


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,

  1. Select ->Properties of project
  2. Go to the reference 3.check the reference of assembly exists or not
  3. if path showing "The system cannot find the reference specified"
  4. download latest MySql connector/Net from https://dev.mysql.com/downloads/connector/net/ for .Net Mono
  5. remove the reference and add the new reference from visual studio-Proerties-reference



回答3:


Try this,

  1. Double click in My Project.
  2. In the tab "References" remove MySQL.Data.
  3. Try to re-install it again.


来源:https://stackoverflow.com/questions/15587233/unable-to-import-mysql-data-mysqlclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!