简体   繁体   中英

Reference System.Data in Visual Studio 2015 UNITY project

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:

在此处输入图片说明

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

在此处输入图片说明


And some more red lines:

在此处输入图片说明

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

在此处输入图片说明

I also have this annoying yellow icon in VS:

在此处输入图片说明

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM