简体   繁体   中英

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:

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 .

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. This is a Xamarin C# solution, and the project that does not list System.Data is a PCL.

Does this affect the packages? If so, is there some way to work around this or get MySQL.Data working without this?

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 ).

Thus, Xamarin C# does not require reference to System.Data. One option is to use JSON as a data format for communication.

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.

I got this issue when using Postgres Driver (Npgsql) which requires at least this framework version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Why am I getting: The type 'IThirdParty' is defined in an assembly that is not referenced. You must add a reference to assembly 'ThirdPartyAssembly'? The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives' 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 The type 'System.Data.Common.DbTransaction' is defined in an assembly that is not referenced. You must add a reference to assembly type 'IReportServerCredentials' is defined in an assembly that is not referenced. The type 'IAsyncOperationWithProgress<,>' is defined in an assembly that is not referenced. NSubstitute -3.x 'ValueType' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, System.IObserver'1<T0> is defined in an assembly that is not referenced. You must add a reference to assembly The type 'IEnumerable<>' is defined in an assembly that is not referenced. System.Runtime
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM