在SQL连接期间Xamarin Android应用程序中缺少dll System.Net.Security.Native

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在SQL连接期间Xamarin Android应用程序中缺少dll System.Net.Security.Native相关的知识,希望对你有一定的参考价值。

在广泛搜索该dll的任何参考之后,我来这里寻求帮助。

我正在尝试建立与承载我的PC的SQL Server数据库的连接(我知道这不是最佳实践,但决定不取决于我)。我已经将android设备通过其扩展坞/ USB连接到了我的PC,并且正在从Visual Studio 2019的设备中以调试模式运行代码。

代码编译并成功在设备上运行,直到我进行connection.Open()调用。到达那里后,我将获得多个DllNotFoundExceptions和一个SQLException,它们均引用此未找到的System.Net.Security.Native库。

我经历过NuGet添加的所有听起来像它们可能包含我要寻找的软件包的软件包,但到目前为止还算不上。我也尝试添加任何听起来相关的参考,但同样,什么也没有。

我也曾尝试添加using System.Net.Security.Native;,但VS只是告诉我

Error CS0234 The type or namespace name 'Native' does not exist in the namespace 'System.Net.Security' (are you missing an assembly reference?)

删除“ Native”也不能解决问题。

这里是“输出”窗格中的日志,以便您可以确切地看到它在寻找什么。

02-04 20:15:52.362 D/Mono    (30702): DllImport attempting to load: 'System.Net.Security.Native'.
02-04 20:15:52.364 D/Mono    (30702): DllImport error loading library './System.Net.Security.Native': 'dlopen failed: library "./System.Net.Security.Native" not found'.
02-04 20:15:52.364 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.365 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.365 D/Mono    (30702): DllImport error loading library '/system/lib64/System.Net.Security.Native': '(null)'.
02-04 20:15:52.365 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.365 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.366 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.367 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.368 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.368 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.369 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native': 'dlopen failed: library "./libSystem.Net.Security.Native" not found'.
02-04 20:15:52.369 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.370 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.370 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native': '(null)'.
02-04 20:15:52.370 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.370 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.371 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.372 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.374 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.375 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.375 W/Mono    (30702): DllImport unable to load library 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.375 D/Mono    (30702): DllImport attempting to load: 'System.Net.Security.Native'.
02-04 20:15:52.376 D/Mono    (30702): DllImport error loading library './System.Net.Security.Native': 'dlopen failed: library "./System.Net.Security.Native" not found'.
02-04 20:15:52.377 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.378 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.378 D/Mono    (30702): DllImport error loading library '/system/lib64/System.Net.Security.Native': '(null)'.
02-04 20:15:52.378 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.378 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.379 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.380 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.381 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.382 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.383 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native': 'dlopen failed: library "./libSystem.Net.Security.Native" not found'.
02-04 20:15:52.383 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.383 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.384 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native': '(null)'.
02-04 20:15:52.384 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.384 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.385 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.386 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.386 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.387 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.387 W/Mono    (30702): DllImport unable to load library 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.393 D/Mono    (30702): DllImport attempting to load: 'System.Net.Security.Native'.
02-04 20:15:52.394 D/Mono    (30702): DllImport error loading library './System.Net.Security.Native': 'dlopen failed: library "./System.Net.Security.Native" not found'.
02-04 20:15:52.394 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.395 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.395 D/Mono    (30702): DllImport error loading library '/system/lib64/System.Net.Security.Native': '(null)'.
02-04 20:15:52.395 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.395 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.396 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.396 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.397 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.398 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.398 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native': 'dlopen failed: library "./libSystem.Net.Security.Native" not found'.
02-04 20:15:52.399 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.399 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.400 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native': '(null)'.
02-04 20:15:52.400 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.400 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.401 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.401 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.402 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.403 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.403 W/Mono    (30702): DllImport unable to load library 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.403 D/Mono    (30702): DllImport attempting to load: 'System.Net.Security.Native'.
02-04 20:15:52.404 D/Mono    (30702): DllImport error loading library './System.Net.Security.Native': 'dlopen failed: library "./System.Net.Security.Native" not found'.
02-04 20:15:52.404 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.404 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.405 D/Mono    (30702): DllImport error loading library '/system/lib64/System.Net.Security.Native': '(null)'.
02-04 20:15:52.405 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.405 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.405 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.406 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.406 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.407 D/Mono    (30702): DllImport error loading library 'System.Net.Security.Native': 'dlopen failed: library "System.Net.Security.Native" not found'.
02-04 20:15:52.407 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native': 'dlopen failed: library "./libSystem.Net.Security.Native" not found'.
02-04 20:15:52.408 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.408 D/Mono    (30702): DllImport error loading library './libSystem.Net.Security.Native.so': 'dlopen failed: library "./libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.408 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native': '(null)'.
02-04 20:15:52.408 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.409 D/Mono    (30702): DllImport error loading library '/system/lib64/libSystem.Net.Security.Native.so': '(null)'.
02-04 20:15:52.410 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.411 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.413 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native.so': 'dlopen failed: library "libSystem.Net.Security.Native.so" not found'.
02-04 20:15:52.413 D/Mono    (30702): DllImport error loading library 'libSystem.Net.Security.Native': 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
02-04 20:15:52.413 W/Mono    (30702): DllImport unable to load library 'dlopen failed: library "libSystem.Net.Security.Native" not found'.
**System.DllNotFoundException:** 'System.Net.Security.Native assembly:<unknown assembly> type:<unknown type> member:(null)'

我还附上了我安装的软件包以及参考的屏幕截图。

Installed Packages

enter image description here

我也收到此警告,但不确定是否与此相关。

XA5302: Two processes may be building this project at once. Lock file exists at path: C:UsersuserDocumentsDownloadsXamarinScannerAndroidXamarinScannerAndroidXamarinScannerAndroidobjDebug81.__lock

恐怕我已经用尽了所有的谷歌搜索功能。如果您还有其他需要(代码段/屏幕截图/等),请告诉我。谢谢!

编辑1:也添加了我的Android选项页面的屏幕截图,包括链接选项。

enter image description here

答案

@zack-f,我没有找到您的解决方案,您能告诉我吗?我正在为同样的错误而苦苦挣扎。谢谢!

以上是关于在SQL连接期间Xamarin Android应用程序中缺少dll System.Net.Security.Native的主要内容,如果未能解决你的问题,请参考以下文章

使用 SQL/SQLite 工具箱 Visual Studio 2019 在 SQLite 数据库和 Xamarin.Android 项目之间建立连接

C# + SQL + Xamarin Android:

Xamarin Android 调用 WebAPI 连接失败

Xamarin Android 错误 XA0136 部署错误

通过USB连接到Xamarin.Android应用程序与网站进行通信

将 Xamarin 表单与 Azure SQL 数据库连接