Mario Mario - 3 years ago 271
MySQL Question

How to add the MySQL Connector to a UWP C# app?

I am using Visual Studio 2015 the community version.
When I try to add the MySQL Connector in the references it will fail even when I try to add it via NuGet Packages it still fails.

I have tried searching the web for solutions but I kept getting the same result, failure.
I have no idea where to get a .NETCore version of MySQL Connector.

Here is my error


Answer Source

As your exception image suggested, the error is clearly:

The project targets '.NETCore' while the file reference targets '.NetFramework'. This is not a supported scenario.

To see the difference between them, you can refer to the answer here: How does Windows 8 Runtime (WinRT / Windows Store apps / Windows 10 Universal App) compare to Silverlight and WPF? [closed].

For the MySQL Connector for WinRT, you can refer to Chapter 7 Connector/Net Support for Windows Store.

Just tested, you can download mysql-connector-net-6.7.9.msi here, if your device has installed higher version of connector like 6.9.9, you probably need to remove it and install this 6.7.9 version. (Don't know why, as my test result, it seems 6.9.9 doesn't have MySql.Data.RT.dll, didn't look into it, it is possible that I didn't install it correctly, anyway 6.7.9 works for me.)

Then you can find the MySql.Data.RT.dll in your MySQL connector installed path for example: C:\Program Files (x86)\MySQL\MySQL Connector Net 6.7.9\Assemblies\RT, and for UWP app, you can reference this .dll file successfully:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download