Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

c# - 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:

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 AssembliesMicrosoftFramework.NETFrameworkv3.5ProfileUnity Subset v3.5


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...