mysql - 仅使用 xamarin Andriod 连接到 mySQL 数据库时出现问题,但在 iOS 和 UWP 中有效
问题描述
我从 Xamarin 跨平台应用程序直接连接到 mySQL 服务器(仅用于学习目的)。该连接在 iOS 和 UWP 中运行良好,但在 android 中它会在此行中引发错误:await conn.OpenAsync();
这是完整的错误:
{System.TypeInitializationException:“MySql.Data.MySqlClient.MySqlConfiguration”的类型初始化程序引发了异常。---> System.Configuration.ConfigurationErrorsException:配置系统初始化失败---> System.PlatformNotSupportedException:此平台不支持操作。在 System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 在 System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018 ] 在 <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 在 System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] 在 <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 在 System.Configuration.ClientConfigurationHost.GetStreamName (System.
希望有人可以帮助我解决这个错误提前谢谢
解决方案
我使用的是 MySql.Data 包,显然它还不支持 Android
解决方法是:使用 MySqlConnector 包。
旁注:MySqlConnector 包不适用于:await conn.openAsync(); 我不得不使用: conn.open();
它适用于 iOS、Android 和 UWP。
推荐阅读
- python - How to plot/scatter geo coordinates in python pandas
- python - Python 具有多个元素的数组的真值是不明确的。使用 a.any() 或 a.all()
- android - 即使在 android 应用程序被杀死后也发送通知
- php - 在 PHP 中打印多维数组的特定部分
- sql - PostgreSQL 从 csv 插入多行
- r - 为什么 R 中的 plot() 在按列的值对数据框进行排序后不反映数据?
- amazon-web-services - 在进行远程/云开发时访问开发服务器
- string - 包含转义符文的 GO 标志 pkg 读取选项字符串(如“\u00FC”)不会读取
- python-3.x - Python 3.7.5 Mariadb 10.4.11 查询绑定导致异常
- python - python路径错误,【WinError 3】系统找不到指定的路径