Before updating to Windows 10 you may need to return your Pro license. More information here

Compiler error with MySQL connection in Unity 3 (System.Drawing)


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=, 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


The problem is that the file "MySql.Data.dll" includes System.Drawing

Any suggestions?

Thanks in advance


more ▼

asked Oct 06, 2010 at 01:40 PM

avatar image

293 26 21 47

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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!


more ▼

answered Oct 28, 2010 at 02:56 PM

avatar image

293 26 21 47

You can also download MySql.Data.dll from official MySql site, make sure it's version 6.0.x, and instead of setting API compatibility, you can copy from c:/windows/mono/mono-2.0/lib/mono/gac/System.Drawing/ to Assets/

Feb 21 at 10:56 PM Radivarig
(comments are locked)
10|3000 characters needed characters left

you are the boss!

more ▼

answered Sep 16, 2014 at 08:51 PM

avatar image

114 1 2 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Oct 06, 2010 at 01:40 PM

Seen: 5738 times

Last Updated: Feb 21 at 10:57 PM