【问题标题】:System.IO.FileNotFoundException Could not load assembly System.Configuration Perhaps it doesn't exist in the Mono for Android profileSystem.IO.FileNotFoundException 无法加载程序集 System.Configuration 也许它在 Mono for Android 配置文件中不存在
【发布时间】:2018-08-19 14:50:28
【问题描述】:

我有以下错误:

它只发生在android上,在ios上一切都很好。

仅当我以 xamarin 形式将 pcl 引用到我的 pcl 时,才会出现该错误。

我在 Xamarin 表单中的 PCL:

我的 PCL:

我读到了:

Add a reference to a class library which target .NET standard 2.0 to a Xamarin PCL which targets .NET Standard 4.5

https://mallibone.com/post/using-pcl-only-libraries-with-net-standard https://montemagno.com/installing-a-pcl-into-netstandard-libraries/

【问题讨论】:

  • 为什么要尝试使用 2 PCL?仅使用 .net 标准 2.0 之一。
  • 我需要在非 .net 标准 2.0 的不同项目之间共享代码。只有一个类,在我的 pcl 中我没有安装任何 Nuget
  • 您不能在您的 android 应用上使用 .net framework 4.7.1。您必须在此处查看.NET Standard implementation support 以确保 android 应用符合要求。
  • 复制旧代码到.net std 2.0项目

标签: .net xamarin xamarin.forms xamarin.android .net-standard


【解决方案1】:

只有当我以 xamarin 形式将 pcl 引用到我的 pcl 时,才会出现该错误。

您在 .Net Standard 2.0 PCL 中引用了 .Net 4.7.1 PCL,它们彼此不是 100% 兼容。从您的错误消息来看,您在 .Net PCL 中使用了 System.Configuration.CertainClass,这在 .Net 标准中不存在。

因此,您需要做的是创建一个 .Net Standard 2.0 PCL 并在您的 PCL 中引用它,复制所有代码并尝试清除不兼容的部分。

您可以在File->New->Project-.Net Standard->Class Library(.Net Standard) 下找到.Net Standard PCL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多