如何使用 C++ 将 Mysql.data.dll 添加到 uwp 中? [英] How do I add Mysql.data.dll into uwp with c++?

查看:34
本文介绍了如何使用 C++ 将 Mysql.data.dll 添加到 uwp 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试在 UWP 中使用带有 C++ 的 Mysql 2 天了......但我无法这样做.

我已经通过 Nuget 安装了 Mysql.data 和 Mysql.ConnectorNet.Data.

但是当我尝试使用 Mysql obejct 时,我找不到任何东西.智能也不起作用,所以我尝试直接添加Mysql.data.dll,但我也做不到.我刚刚收到一条错误消息.它说无法添加对我的路径"的引用,因为它不是当前项目可以使用的类型或版本."

有人知道怎么解决吗?

解决方案

Mysql 官方网站没有提供 C++/CX 可以直接使用的 dll.你提到的Mysql.data.dll"这个dll实际上是winrt .net的一个dll,不能直接在C++/CX中使用.

参见 MSDN 文档:如何: 在通用 Windows 平台应用程序中使用现有的 C++ 代码

您会发现:不要在解决方案资源管理器的引用节点中添加引用.该机制仅适用于 Windows 运行时组件."所以实际上您可以通过创建一个新的简单 Windows 运行时组件来测试它是什么.

可能的开始方式是

  1. 阅读上面的 msdn 文档并使用位于 C:\Program Files\MySQL\MySQL Connector C++ 1.1.9\lib\opt 下的本地 C++ mysql 库(安装本地 C++ 连接器后,您可以找到它).(使用静态库时我还没有计算出来.)
  2. 或者直接使用 github 中的代码创建 C++ winrt 版本的 dll.

由于在调查时这可能需要大量时间,我认为您最好考虑使用一些现有的数据库技术.就像 UWP 建议的 sqlite 数据库.>

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?

解决方案

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

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

这篇关于如何使用 C++ 将 Mysql.data.dll 添加到 uwp 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆