简体   繁体   English

类型“ DbConnection”在未引用的程序集中定义。 我无法添加参考?

[英]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.

相关问题 为什么我得到:“IThirdParty”类型是在未引用的程序集中定义的。 您必须添加对程序集“ThirdPartyAssembly”的引用吗? - Why am I getting: The type 'IThirdParty' is defined in an assembly that is not referenced. You must add a reference to assembly 'ThirdPartyAssembly'? “System.Object”类型在未引用的程序集中定义。 您必须添加对程序集 .netstandard 的引用 - The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard “组件”类型是在未引用的程序集中定义的。 您必须添加对程序集“System.ComponentModel.Primitives”的引用 - The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives' “MarshalByRefObject”类型是在未引用的程序集中定义的。 您必须添加对程序集 &#39;mscorlib, Version=4.0.0.0 的引用 - The type 'MarshalByRefObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0 类型“ System.Data.Common.DbTransaction”在未引用的程序集中定义。 您必须添加对程序集的引用 - The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly 类型“ IReportServerCredentials”在未引用的程序集中定义。 - type 'IReportServerCredentials' is defined in an assembly that is not referenced. 类型&#39;IAsyncOperationWithProgress &lt;,&gt;&#39;在未引用的程序集中定义。 - The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced. NSubstitute -3.x &#39;ValueType&#39; 在未引用的程序集中定义。 您必须添加对程序集“netstandard”的引用, - NSubstitute -3.x 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, System.IObserver&#39;1 <T0> 在未引用的程序集中定义。 您必须添加对程序集的引用 - System.IObserver'1<T0> is defined in an assembly that is not referenced. You must add a reference to assembly “IEnumerable &lt;&gt;”类型在未引用的程序集中定义。 System.Runtime - The type 'IEnumerable<>' is defined in an assembly that is not referenced. System.Runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM