Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception caught Method not found: Microsoft.AspNetCore.Http.Connections.NegotiationResponse on iOS

The code seems to work with UWP in Xamarin.Forms but when i try this with iOS i get the following error

Exception caught Method not found: Microsoft.AspNetCore.Http.Connections.NegotiationResponse Microsoft.AspNetCore.Http.Connections.NegotiateProtocol.ParseResponse

Is there something that needs to be updated in iOS for this to work?

I am using Microsoft.AspNetcore.SignalrClient v 5.0.4.

This was working in previous versions, any ideas?

like image 874
Curtis-C Avatar asked Mar 25 '21 07:03

Curtis-C


2 Answers

You might find a workaround here:

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

Basically the solution is modifying the iOS.csproj file to include

    <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>

as in this commit

enter image description here

like image 106
deczaloth Avatar answered Sep 27 '22 17:09

deczaloth


Modifying the iOS.proj does not work for everyone. The issue is actually VS2022 related.

Possible solutions:

  1. Disable XAML hot reload in VS2022 (Debug > Options > XAML Hot Reload > Disable Hot Reload for Xamarin.Forms)

  2. Use VS2019

Last update on the issue (November 2021) from MSFT:

In Visual Studio 2019, XAML Hot Reload used “BinaryFormatter” for serialization and deserialization of messages between the Hot Reload agent, and the IDE. For VS 2022, we deprecated that (as it wouldn’t work with .NET 6 and also BinaryFormatter has issues of its own) and moved to Protobuf. For that to work, we load additional dependencies to support it, such as System.Memory and System.Buffers if it wasn’t already loaded by the application. This seems to be the root of the problem. Depending on other dependencies loaded, it can conflict and cause issues like this one.

We’re researching how to handle this.

like image 40
troshanov94 Avatar answered Sep 27 '22 18:09

troshanov94