MySQL commands not working in .exe, only inside Unity.

Hey guys, recently I’ve been trying to implement mySQL with C# and I could done some nice things like add new values into tables of my database via C# script inside my project. The problem is that when I build the project as .exe mySQL integration don’t work properly. When I checked out the output log I figured out this error:

(Filename:  Line: -1)

TypeLoadException: Could not load type 'MySql.Data.MySqlClient.MySqlConnection' from assembly 'MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.

What that error means? How can I fix it? The MySQL part in my script is the following:

void Start () {


	 string connectionString = "Server=localhost;" + "Database=cadastro;" + "User ID=root;" +
      "Password=mypass;" + "Pooling=false";
      
   	MySqlConnection dbcon = new MySqlConnection(connectionString);
   
    dbcon.Open();
   
    MySqlCommand dbcmd = dbcon.CreateCommand();
	string newCommand = ("INSERT INTO login VALUES (" + 1 + ", 'newuser', 'newpassword');");
	
	dbcmd.CommandText = newCommand;
	
	}

IMPORTANT : My script’s using MySql.Data.MySqlClient; and the file is in my Assets folder.

Problem solved after change the S.O. (:

The solution is here :
The unity player need some additionals DLL (internationalization libraries).

You must copy them from :
C:\program files(x86)\unity\Editor\Data\Mono\Lib\mono\unity\

  • I18n.dll
  • I18n.West.dll
    (personnaly, i’ve also copied the 4 others).

And paste next to your other DLL, in your project tree.

The source link is here :