- Home /
Compiler error with MySQL connection in Unity 3 (System.Drawing)
Hello,
I have a problem with a script to connect to a DataBase with MySQL. It works ok in Unity 2.6.1, but it doesn't work in Unity 3. I read in forums that "System.Drawing" is not supported in Unity 3.
This is the error:
Internal compiler error. See the console log for more information. output was: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
This is my script:
using UnityEngine; using MySql.Data.MySqlClient; using System; using System.Data; using System.Collections.Generic
public class NewBehaviourScript : MonoBehaviour { void Start () { string connectionString = [.....] //Hidden for security
MySqlConnection dbConnection = new MySqlConnection(connectionString);
} }
I also copied the next files to the Assets folder of my project
I18N.dll
I18N.West.dll
MySql.Data.dll
System.Data.dll
The problem is that the file "MySql.Data.dll" includes System.Drawing
Any suggestions?
Thanks in advance
Joel
Answer by jsr2k1 · Oct 28, 2010 at 02:56 PM
The solution is:
Copy only the file "MySql.Data.dll" from c:\Program Files (x86)\MySQL\MySQL Connector Net 6.0.3\Assemblies\ to the Assets folder of your project
and change: Player Settings-->Optimization-->Api Compatibility Level = .NET 2.0
That's it!
Joel
You can also download $$anonymous$$ySql.Data.dll from official $$anonymous$$ySql site, make sure it's version 6.0.x, and ins$$anonymous$$d of setting API compatibility, you can copy from c:/windows/mono/mono-2.0/lib/mono/gac/System.Drawing/2.0.0.0__/System.Drawing.dll to Assets/
Your answer
![](https://koobas.hobune.stream/wayback/20220613074917im_/https://answers.unity.com/themes/thub/images/avi.jpg)