c# - 引用 Visual Studio 2015 UNITY 项目中的 System.Data

标签 c# visual-studio unity3d mono

我正在为我的 Unity 项目使用 Visual Studio。 (Unity 使用的是单声道框架,而不是 .net)。我正在使用数据库,所以我必须在我保存在 Assets /插件文件夹中的项目中使用 System.Data.dll:

enter image description here

如您所见,Visual Studio 在查看 System.Data 库时遇到问题。所以我正在硬编码:

enter image description here


还有一些红线:

enter image description here

令人惊讶的是,我在 Unity 中没有任何错误,而且代码确实有效:

enter image description here

我在 VS 中也有这个烦人的黄色图标:

enter image description here

你能帮我强制 Visual Studio 查看 System.Data 库吗?

最佳答案

System.Data.dllSystem.MySql.dllSystem.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/

相关文章:

c# - 为什么类中定义的委托(delegate)不能被类对象访问

c# - 无法从 xtragridview 获取点击行的数据

c# - 登录托管 NancyFx Web 服务的控制台应用程序

Visual Studio 2019 能否将所需的 DLL 打包到一个小的 .exe 文件中?

c# - 按钮 onClick 未绑定(bind)到 Activity 中的方法

c - 这个结构体语法背后的原理是什么?我怎样才能让 Visual Studio 接受它是正确的?

visual-studio - 是否有用于检测具有重复 GUID 的 Visual Studio 项目的工具?

c# - 如何检测 UI 和 GameObjects 上的点击/触摸事件

c# - 不使用 Fortune 算法生成 Voronoi 图

c# - 在 C# for Unity 中非阻塞加载和复制大型 Texture2D