我正在为我的 Unity 项目使用 Visual Studio。 (Unity 使用的是单声道框架,而不是 .net)。我正在使用数据库,所以我必须在我保存在 Assets /插件文件夹中的项目中使用 System.Data.dll:
如您所见,Visual Studio 在查看 System.Data 库时遇到问题。所以我正在硬编码:
还有一些红线:
令人惊讶的是,我在 Unity 中没有任何错误,而且代码确实有效:
我在 VS 中也有这个烦人的黄色图标:
你能帮我强制 Visual Studio 查看 System.Data 库吗?
最佳答案
System.Data.dll、System.MySql.dll 和System.Drawing.dll 都应该放在 Assets 文件夹不在 Assets/Plugin 文件夹中。进行这些更改可以避免错误。
编辑:
将 System.Data.dll 添加到 Assets 文件夹应该可以,但会无提示地失败。深入研究这个问题,我得到了这个错误:
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".
因此,System.Data.dll 版本与您的目标框架不同,这就是问题所在。您需要与目标框架 (2.0.0.0) 相同版本的 System.Data.dll。
您可以从以下位置获得兼容版本 (2.0.0.0):
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Subset v3.5
关于c# - 引用 Visual Studio 2015 UNITY 项目中的 System.Data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40399362/