Unity and the dlls.

Hi, first sorry for my English I don’t speak very well, I’ll try my best for you understand me.

So, I’m trying to use dll for connect Unity to SQL (it’s not the problem), I use C#.
I start my script like this :

using UnityEngine;
using System;
using System.Data;
using System.Data.SqlClient;

So Unity send me an error : “‘Data’ does not exist in the namespace ‘System’”.
Here it is ok, I paste the System.Data.dll in the project folder “…/MyProject/Assets/DLLs/”.

Note that I add this version of dll : 4.0.30319.18047 (one of the latest).

So, the error disappear, but now it say : “Could not load type ‘System.Threading.Tasks.Task’ from assembly ‘mscorlib’”.

I make test with Visual Studio and MonoDevelop, the result is…

System.Data.dll make a reference to “System.Threading.Tasks.Task” and say to Unity to search in the .NET 2.0 for the file. Unity found the mscorlib.dll in the folder and… the dll is outdated… effectively “Tasks.Task” doesn’t exist. I watch the .NET 4.0 mscorlib.dll and in this version “Tasks.Task” exist.

So why my dll say to use an outdated version? Why Unity don’t use by itself the latest version? Why I can’t choose my version?

I’ve try to paste the good mscorlib.dll in my “./DLLs/” folder but no effect, I try to include the good dll in the Project Reference no effect or double file error depending on how I arrange the script.

After I think “Hey if you use a anterior version of System.Data.dll probably it’s doesn’t search for Tasks.Task”. And a lot of error appear.

Am I damned?

Someone can help me?

The problem is you’re probably adding System.Data.dll from standard .NET Framework, which requires mscorlib provided by Microsoft. You have to use Mono implementation of System.Data.dll, which you can find under:

C:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\unity

Out of the box this will work in Editor, but not after build. At least id didn’t worked for me - I got “CodePage 1252 not supported”. After a bit of googling, I found this info. Adding I18N.dll and I18N.West.dll to the project, fixed the problem.