问题
I have been to try to use Mysql with c++ in UWP for 2 days...but I could not do so.
I already installed Mysql.data and Mysql.ConnectorNet.Data through Nuget.
However when I tried to use Mysql obejct, I couldn't find anything. Intelligence does not work too so I tried to add Mysql.data.dll directly, but I couldn't do too. I just got a error message. It said that "could not add a reference to "my path" as it is not of a type or version current proejct can use."
Does anyone know how to solve it?
回答1:
Mysql doesn't provide a dll which can be directly used by C++/CX in its official site. The dll you mentioned "Mysql.data.dll" is actually a Dll for winrt .net which can not be directly used in C++/CX.
See MSDN docs:How to: Use Existing C++ Code in a Universal Windows Platform App
You will find this:"Do not add a reference in the References node in Solution Explorer. That mechanism only works for Windows Runtime Components." So actually you can test by create a new simple Windows Runtime Component to see what it is.
Possible ways to start are
- Read the above msdn doc and use native C++ mysql library which is located under C:\Program Files\MySQL\MySQL Connector C++ 1.1.9\lib\opt(After installed the native C++ Connector you can find it). ( I haven't worked out when using static library yet.)
- Or Directly use the code from it's github to create a C++ winrt version dll.
As this may need lots of time when investigating I think it's better for you to think about using some exist database technology. Like UWP suggested sqlite database.
来源:https://stackoverflow.com/questions/44643438/how-do-i-add-mysql-data-dll-into-uwp-with-c