Question by
GerryHmm · Sep 03, 2017 at 03:51 PM ·
standalonemysqltypeloadexception
Unity 2017 Mysql not working in built exe
There are a few of these questions already asked on this forum but none of them seems to work for me. When i build my project mysql doesn't work and i get this error.
TypeLoadException: A type load exception has occurred.
I have added the mysql.data.dll to the plugins folder and these dlls to.
System.Data.dll
I18N.dll
I18NWest.dll
MySql.Data.dll
System.Security.dll
System.Drawing.dll
System.Configuration.dll
System.EnterpriseService.dll
System.Managment.dll
Here is the mysql code and the imports.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using MySql.Data.MySqlClient;
public class Server : NetworkManager {
void onLogin(NetworkMessage msg)
{
LoginPacket packet = msg.ReadMessage<LoginPacket>();
string connectionString = "Server=" + host + ";Database=" + database + ";Uid=username;Pwd=****;";
MySqlConnection mysqlConn = new MySqlConnection(connectionString);
mysqlConn.Open();
MySqlCommand getLogin = new MySqlCommand("SELECT * FROM accounts WHERE name='" + packet.name + "' AND password='" + packet.password + "' ",mysqlConn);
MySqlDataReader reader = getLogin.ExecuteReader();
int amt = 0;
while (reader.Read())
{
//string result = reader.GetString(0);
amt++;
}
Debug.Log("amount: " + amt);
LoginPacket pack = new LoginPacket();
if (amt > 0)
{
pack.successfull = true;
}
Debug.Log("amount" + amt);
NetworkServer.SendToClient(msg.conn.connectionId, PacketTypes.LOGIN, pack);
}
}
The Mysql works fine when it's in the editor but not when built. I have tried what everyone has said but none worked for me. I have no idea of to fix this and would appriciate some help.
Thanks.
Comment
Answer by ayman-on · May 11, 2018 at 03:32 PM
mee too. I tried SQLite and MySQL, Local and Host, all zero working in android but perfect working in the editor