'unable to import MySql.Data.MySqlClient

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.



Solution 1:[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

Solution 2:[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

Solution 3:[3]

Try this,

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 iain
Solution 2
Solution 3 Edgar Conrado