[英]The type 'DbConnection' is defined in an assembly that is not referenced. I cannot add the reference?
In Visual Studio (same issue in 2013 & 2015 Editions), I am getting this error when building my project: 在Visual Studio(2013和2015版中相同的问题)中,构建项目时出现此错误:
The type 'DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0
I am doing this as I would like to use the MySQL.Data
package, but it seems to require System.Data
. 我这样做是因为我想使用
MySQL.Data
包,但它似乎需要System.Data
。
However, in my project there is no way to add System.Data
to my references, it is not in the list of references so I cannot 'tick' it to add it to the project. 但是,在我的项目中无法将
System.Data
添加到我的引用中,它不在引用列表中,因此我无法“选择”它以将其添加到项目中。 This is a Xamarin C#
solution, and the project that does not list System.Data
is a PCL. 这是
Xamarin C#
解决方案,未列出System.Data
的项目是PCL。
Does this affect the packages? 这会影响包装吗? If so, is there some way to work around this or get MySQL.Data working without this?
如果是这样,是否有某种方法可以解决此问题或使MySQL.Data在没有此情况的情况下工作?
I think a better approach is to not connect from your application directly to the database ( 2-tier
), but define a Web service
to consume and that Web service will connect to the database ( 3-tier
). 我认为更好的方法是不将应用程序直接连接到数据库(
2-tier
),而是定义要使用的Web service
,并且该Web服务将连接到数据库( 3-tier
)。
Thus, Xamarin C#
does not require reference to System.Data. 因此,
Xamarin C#
不需要引用System.Data。 One option is to use JSON
as a data format for communication. 一种选择是使用
JSON
作为通信的数据格式。
More details about this problem are discussed here . 这里讨论有关此问题的更多详细信息。
I know this is an old question but i solved it by just upgrading my project .Net Framework to 4.5. 我知道这是一个老问题,但是我通过将项目.Net Framework升级到4.5来解决了。
I got this issue when using Postgres Driver (Npgsql) which requires at least this framework version. 在使用至少需要此框架版本的Postgres驱动程序(Npgsql)时遇到此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.