在 Visual Studio 2015 UNITY 项目中引用 System.Data
Reference System.Data in Visual Studio 2015 UNITY project
我正在为我的 Unity 项目使用 Visual Studio。 (Unity 使用的是单声道框架,而不是 .net)。我正在使用数据库,所以我必须在我保存在 Assets/Plugins 文件夹中的项目中使用 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 版本与您的目标框架不同,这就是问题所在。您需要另一个版本的 System.Data.dll 与您的目标框架 (2.0.0.0).
相同的版本
您可以从以下位置获得兼容版本(2.0.0.0):
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Subset
v3.5
我正在为我的 Unity 项目使用 Visual Studio。 (Unity 使用的是单声道框架,而不是 .net)。我正在使用数据库,所以我必须在我保存在 Assets/Plugins 文件夹中的项目中使用 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 版本与您的目标框架不同,这就是问题所在。您需要另一个版本的 System.Data.dll 与您的目标框架 (2.0.0.0).
相同的版本您可以从以下位置获得兼容版本(2.0.0.0):
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Subset v3.5