Reputation: 133
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?
Upvotes: 9
Views: 1550
Reputation: 61
I noticed in the IOS .csproj, some lib targeted netstandard2.1 instead of 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>
Switching back to netstandard2.0 worked for me. (My Common library is a 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>
Upvotes: 1
Reputation: 31
Modifying the iOS.proj does not work for everyone. The issue is actually VS2022 related.
Possible solutions:
Disable XAML hot reload in VS2022 (Debug > Options > XAML Hot Reload > Disable Hot Reload for Xamarin.Forms)
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.
Upvotes: 3
Reputation: 7475
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
Upvotes: 13