【问题标题】:Exception caught Method not found: Microsoft.AspNetCore.Http.Connections.NegotiationResponse on iOS发现异常方法未找到:iOS 上的 Microsoft.AspNetCore.Http.Connections.NegotiationResponse
【发布时间】:2022-01-26 00:58:51
【问题描述】:

代码似乎与 Xamarin.Forms 中的 UWP 一起使用,但是当我使用 iOS 尝试此操作时,我收到以下错误

异常捕获方法未找到: Microsoft.AspNetCore.Http.Connections.NegotiationResponse Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse

是否需要在 iOS 中进行更新才能使其正常工作?

我正在使用 Microsoft.AspNetcore.SignalrClient v 5.0.4。

这在以前的版本中有效,有什么想法吗?

【问题讨论】:

  • 您的设备的 ios 版本是多少?它支持使用 Xamarin.iOS 11.14.0.4 及更高版本的 iOS 应用程序。您可以查看 MS 文档以获取更多详细信息。 docs.microsoft.com/en-us/aspnet/core/signalr/…
  • 我们使用 ios 14.1 进行测试。任何其他想法
  • 我刚刚使用示例 github 信号器测试进行了尝试,但我得到了相同的错误 Method not found: Microsoft.AspNetCore.Http.Connections.NegotiationResponse Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse( System.ReadOnlySpan`1)
  • @Curtis-C 这些链接有用吗:github.com/xamarin/xamarin-macios/issues/10592github.com/dotnet/aspnetcore/issues/29762?它们似乎是相似的问题。

标签: ios xamarin.forms signalr


【解决方案1】:

您可能会在此处找到解决方法:

https://github.com/mono/mono/issues/20805#issuecomment-841321110

基本上解决方案是修改 iOS.csproj 文件以包含

    <PackageReference Include="System.Buffers">
      <Version>4.5.1</Version>
      <IncludeAssets>none</IncludeAssets>      
    </PackageReference>
    <PackageReference Include="System.Memory">
      <Version>4.5.4</Version>
      <IncludeAssets>none</IncludeAssets>      
    </PackageReference>

如this commit

【讨论】:

  • 这对我有用。需要注意的一点,我没有仔细阅读,重要的是要注意,&lt;IncludeAssets&gt;none&lt;/IncludeAssets&gt; 是关键。我读了这篇文章,就像,“哦,只是为内存和缓冲区添加 nuget 包”,但你真正在做的是明确排除它们的资源。所以不要只添加 nuget 包,你真的必须编辑 csproj 文件并排除资产。
【解决方案2】:

修改 iOS.proj 并不适合所有人。这个问题实际上是 VS2022 相关的。

可能的解决方案:

  1. 在 VS2022 中禁用 XAML 热重载(调试 > 选项 > XAML 热重载 > 禁用 Xamarin.Forms 的热重载)

  2. 使用 VS2019

MSFT 关于该问题的最新更新(2021 年 11 月):

在 Visual Studio 2019 中,XAML 热重载使用“BinaryFormatter” Hot Reload 之间消息的序列化和反序列化 代理和IDE。对于 VS 2022,我们不推荐使用它(因为它不会 使用 .NET 6 并且 BinaryFormatter 也有自己的问题)和 移至 Protobuf。为此,我们加载了额外的依赖项 支持它,例如 System.Memory 和 System.Buffers 如果不是 已由应用程序加载。这似乎是问题的根源 问题。根据加载的其他依赖项,它可能会发生冲突并且 导致类似这样的问题。

我们正在研究如何处理这个问题。

【讨论】:

  • 他们没有表明他们正在使用 Visual Studio 2022,这绝不是保证,因为 Visual Studio 2022 在发布时处于预览状态。因此,(对我而言)不清楚这是否是导致 OP 问题的原因——尽管它可能对将来遇到此问题的人有用。
【解决方案3】:

我注意到在 IOS .csproj 中,一些 lib 针对 netstandard2.1 而不是 2.0:

    <Reference Include="Microsoft.AspNetCore.Connections.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.Connections.Abstractions.6.0.1\lib\netstandard2.1\Microsoft.AspNetCore.Connections.Abstractions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.Http.Connections.Client, Version=6.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.Http.Connections.Client.6.0.1\lib\netstandard2.1\Microsoft.AspNetCore.Http.Connections.Client.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.Http.Connections.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.Http.Connections.Common.6.0.1\lib\netstandard2.1\Microsoft.AspNetCore.Http.Connections.Common.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.SignalR.Client, Version=6.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.SignalR.Client.6.0.1\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Client.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.SignalR.Client.Core, Version=6.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.SignalR.Client.Core.6.0.1\lib\netstandard2.1\Microsoft.AspNetCore.SignalR.Client.Core.dll</HintPath>
      <Private>True</Private>
    </Reference>

切换回 netstandard2.0 对我有用。 (我的通用库是netstandard2.0)

    <Reference Include="Microsoft.AspNetCore.Connections.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.Connections.Abstractions.6.0.1\lib\netstandard2.0\Microsoft.AspNetCore.Connections.Abstractions.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.Http.Connections.Client, Version=6.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.Http.Connections.Client.6.0.1\lib\netstandard2.0\Microsoft.AspNetCore.Http.Connections.Client.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.Http.Connections.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.Http.Connections.Common.6.0.1\lib\netstandard2.0\Microsoft.AspNetCore.Http.Connections.Common.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.SignalR.Client, Version=6.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.SignalR.Client.6.0.1\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Client.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.AspNetCore.SignalR.Client.Core, Version=6.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
      <HintPath>..\..\packages\Microsoft.AspNetCore.SignalR.Client.Core.6.0.1\lib\netstandard2.0\Microsoft.AspNetCore.SignalR.Client.Core.dll</HintPath>
      <Private>True</Private>
    </Reference>

【讨论】:

    猜你喜欢
    • 2020-10-22
    • 1970-01-01
    • 2023-01-28
    • 2015-06-29
    • 2020-04-20
    • 1970-01-01
    • 2016-06-02
    • 1970-01-01
    • 2022-12-21
    相关资源
    最近更新 更多