【问题标题】:Cannot load System.Net.Http.Primitives in Xamarin iOS无法在 Xamarin iOS 中加载 System.Net.Http.Primitives
【发布时间】:2016-10-23 19:25:54
【问题描述】:

我有一个更新的旧 Xamarin 表单项目,它使用 Microsoft Azure 的移动应用服务(以前使用 Azure 移动服务)。

工作正常,但经过清理和重建后,我现在每次尝试运行它时都会收到此错误(我使用的是 Xamarin Studio)

Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Microsoft.Azure.Mobile.Client 和 SQLiteStore 的版本为 2.0.1。我尝试通过 NuGet 删除和读取程序集,但没有任何运气。

有人看到或解决了这个问题吗?

【问题讨论】:

  • 我做了 - 但是 Microsoft.BCL.Build 1.0.21 和 Microsoft.Net.Http 2.2.29 都已经在项目中,我仍然有一个错误,错误 CS0012 The type 'HttpMessageHandler'在未引用的程序集中定义。您必须添加对程序集“System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”的引用。

标签: azure xamarin xamarin.ios xamarin.forms azure-mobile-services


【解决方案1】:

Xamarin iOS (monotouch) 依赖于 System.Net.Http.Primitives 版本 4.2.29.0,而版本 1.5.0.0 是平台portable-net40+sl4+ win8+wp71+wpa81。正如Eric Hedstrom 评论的那样,您是否尝试过this 答案中的步骤?

【讨论】:

  • 我有,但仍然出现错误。但是我相信我在下面找到了解决方法。
  • 更新 - 看起来解决方法没有。我已经添加了 Microsoft.Bcl.Build 1.0.21 和 Microsoft.Net.Http,但是仍然收到错误类型 System.Net.Http.HttpClientHandler' is defined in an assembly that is not referenced. Consider adding a reference to assembly System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ' (CS0012) 检查是否与 ModernHttpHandler 冲突。
【解决方案2】:

这里的解决方案是重新创建 Xamarin 项目,并将旧项目的可移植类库重新链接到它。

【讨论】:

    【解决方案3】:

    我在使用 ModernHttpHandler 的 Xamarin.iOS 本机项目的解决方案中遇到了类似的错误。

    尝试在 csproj 文件中添加对标准 Mono System.Net.Http 的引用:

    <Reference Include="System.Net.Http" />
    

    更多详情请查看this blog post

    【讨论】:

      猜你喜欢
      • 2015-09-11
      • 2015-07-28
      • 2019-08-24
      • 2016-06-25
      • 2018-07-13
      • 1970-01-01
      • 2015-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多