1

I'm using Visual Studio for my Unity project. (Unity is using mono framework, NOT .net). I'm using a database so I have to use System.Data.dll in the project which i'm keeping in Assets/Plugins folder:

enter image description here

As you can see Visual Studio has problems seeing System.Data library. So I'm hardcoding:

enter image description here


And some more red lines:

enter image description here

Surprisingly, I have no errors in Unity and the code is actually working:

enter image description here

I also have this annoying yellow icon in VS:

enter image description here

Can you help me in forcing Visual Studio to see System.Data library please?

Nika Kasradze
  • 2,834
  • 3
  • 25
  • 48
  • Inside your unity installation folder there should be a system.data. Replace the one in your project, with the one in your installation folder Path probably looks something similar to: `C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity` – MX D Nov 03 '16 at 13:46
  • Yes, thanks, that's the library I'm using, I've re-imported it just in case but still the same – Nika Kasradze Nov 03 '16 at 13:51

1 Answers1

3

The System.Data.dll, System.MySql.dll and System.Drawing.dll should all placed in the Assets folder not in the Assets/Plugin folder. Making these changes get ride of the error.

EDIT:

Adding System.Data.dll to the Assets folder should work but is failing silently. Digging deeper into this, I got this error:

The primary reference "System.Data" could not be resolved because it has a higher version "2.0.5.0" than exists in the current target framework. The version found in the current target framework is "2.0.0.0".

So, the System.Data.dll version is different from your target framework and that is the problem. You need another version of System.Data.dll that is the-same version of your target framework(2.0.0.0).

You can get a compatible version(2.0.0.0) from:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Subset v3.5

Programmer
  • 121,791
  • 22
  • 236
  • 328
  • Thanks @Programmer but it's still same :( strangely the _System.MySql.dll_ and _System.Drawing.dll_ seem fine. It's just _System.Data.dll_ that's bumping my OCD spikes – Nika Kasradze Nov 03 '16 at 14:55
  • Even though it might be fine, they should *all* be placed at Assets folder. Where did you get those DLL's? I want to try it – Programmer Nov 03 '16 at 14:57
  • the _System.Drawing.dll_ and _System.MySql.dll_ are from some Unity forum thread, I was playing with mysql and came across the thread. But the System.Data.dll is from here: C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity – Nika Kasradze Nov 03 '16 at 15:00
  • on mac: /Applications/Unity/Unity.app/Contents/Frameworks/Mono/lib/mono/2.0 – Nika Kasradze Nov 03 '16 at 15:03
  • Ok. Will take a look. Why do you need to access database directly from your app? Do you plan to release this to the public and are you connecting to a server with database? – Programmer Nov 03 '16 at 15:06
  • of course not, I'll probably get an ec2 instance on amazon but for now I'm just curious – Nika Kasradze Nov 03 '16 at 15:07
  • For 2018.2.2+ it seems that Mono/lib no longer exists on Mac? – ina Oct 01 '18 at 22:32
  • @ina Answered your other question. – Programmer Oct 02 '18 at 00:15