Aspnetcore: SignalR v3.0.0-preview3-19153-02 not working in Android Xamarin.Forms project. "System.TypeLoadException: Could not load type of field 'System.Text.Json.Utf8JsonWriter:s_dateTimeStandardFormat'"

Created on 24 Mar 2019  路  12Comments  路  Source: dotnet/aspnetcore

Attempting to connect to a v3.0.0-preview3-19153-02 SignalR service (using Azure's SignalR Service) using an Android Xamarin.Forms application gives the following exception:

System.AggregateException: Unable to connect to the server with any of the available transports. (WebSockets failed: Could not load type of field 'System.IO.Pipelines.Pipe:_reader' (16) due to: Could not resolve type with token 0100002e from typeref (expected class 'System.Threading.Tasks.Sources.IValueTaskSource`1' in assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Threading.Tasks.Sources.IValueTaskSource`1 member:(null)) (ServerSentEvents failed: The transport does not support the 'Binary' transfer format.) (LongPolling failed: Could not load type of field 'System.IO.Pipelines.Pipe:_reader' (16) due to: Could not resolve type with token 0100002e from typeref (expected class 'System.Threading.Tasks.Sources.IValueTaskSource`1' in assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Threading.Tasks.Sources.IValueTaskSource`1 member:(null)) ---> Microsoft.AspNetCore.Http.Connections.Client.TransportFailedException: WebSockets failed: Could not load type of field 'System.IO.Pipelines.Pipe:_reader' (16) due to: Could not resolve type with token 0100002e from typeref (expected class 'System.Threading.Tasks.Sources.IValueTaskSource`1' in assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Threading.Tasks.Sources.IValueTaskSource`1 member:(null) ---> System.TypeLoadException: Could not load type of field 'System.IO.Pipelines.Pipe:_reader' (16) due to: Could not resolve type with token 0100002e from typeref (expected class 'System.Threading.Tasks.Sources.IValueTaskSource`1' in assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Threading.Tasks.Sources.IValueTaskSource`1 member:(null)
  at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat) [0x001c6] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
  at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartTransport (System.Uri connectUrl, Microsoft.AspNetCore.Http.Connections.HttpTransportType transportType, Microsoft.AspNetCore.Connections.TransferFormat transferFormat) [0x000b4] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
  at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport (Microsoft.AspNetCore.Connections.TransferFormat transferFormat) [0x004b4] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
  at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport (Microsoft.AspNetCore.Connections.TransferFormat transferFormat) [0x00567] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
  at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore (Microsoft.AspNetCore.Connections.TransferFormat transferFormat) [0x00118] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
  at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
  at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x0008b] in <4ac1bf8ae2d540ccafed16f06514c1e1>:0 
  at Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory.ConnectAsync (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x0009d] in <8947a218ec4c4a4f81338cd8b5b1247b>:0 
  at Microsoft.AspNetCore.SignalR.Client.HttpConnectionFactory.ConnectAsync (Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00142] in <8947a218ec4c4a4f81338cd8b5b1247b>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) [0x00130] in <e49ca2e500654d99b6021ba11176a922>:0 
  at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <e49ca2e500654d99b6021ba11176a922>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancellationToken) [0x00091] in <e49ca2e500654d99b6021ba11176a922>:0 

After installing System.IO.Pipelines 4.6.0-preview3.19128.7 on my app projects, I get the same exception.

After installing System.Threading.Tasks.Extensions 4.6.0-preview.18571.3 on my app projects, I get this exception:

System.TypeLoadException: Could not load type of field 'System.Text.Json.Utf8JsonWriter:s_dateTimeStandardFormat' (0) due to: Could not resolve type with token 01000052 from typeref (expected class 'System.Buffers.StandardFormat' in assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51') assembly:System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Buffers.StandardFormat member:(null)
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.HandshakeAsync (Microsoft.AspNetCore.SignalR.Client.HubConnection+ConnectionState startingConnectionState, System.Threading.CancellationToken cancellationToken) [0x00056] in <e49ca2e500654d99b6021ba11176a922>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) [0x001ef] in <e49ca2e500654d99b6021ba11176a922>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) [0x002b5] in <e49ca2e500654d99b6021ba11176a922>:0 
  at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <e49ca2e500654d99b6021ba11176a922>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancellationToken) [0x00091] in <e49ca2e500654d99b6021ba11176a922>:0 

After installing System.Memory 4.5.2 on my app projects, I get the same exception.

After installing System.Buffers 4.5.0 on my app projects, I get the same exception.

Is there something special I need to do to use System.Buffers.StandardFormat?

Additional context

This works with UWP, but not Android.

Output of dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview3-010431
 Commit:    d72abce213

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\

Host (useful for support):
  Version: 3.0.0-preview3-27503-5
  Commit:  3844df9537

.NET Core SDKs installed:
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.1.600 [C:\Program Files\dotnet\sdk]
  2.1.601 [C:\Program Files\dotnet\sdk]
  2.1.602 [C:\Program Files\dotnet\sdk]
  2.2.100 [C:\Program Files\dotnet\sdk]
  2.2.105 [C:\Program Files\dotnet\sdk]
  3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview3-27504-2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
accepted area-signalr blocked bug

All 12 comments

We've had issues with System.Memory on Xamarin in the past :(. I'll follow up on this with those folks and see where we are right now.

If you have a repro project you could post that would be a big help :).

Sorry, I don't have a repro project at the moment. I rolled my entire solution back to .NET Core 2.2 and am done trying the preview packages for now, so it is not a pressing issue for me at the moment at least. I figured that this was just a problem of the libraries being out of sync and would be fixed when Core 3.0 was released.

Triage decision: Sounds like Xamarin has a weird System.Memory quirk going on. Need to follow up with Xamarin folks (cc @jamesmontemagno @bradygaster) to see what we can work out here.

Actually it seems most likely that this is because we're using preview builds of corefx packages (like System.Memory) and I know that System.Memory (in particular) is embedded in the Xamarin platform (so upgrading packages doesn't help here). It's likely this is blocked on Xamarin importing the latest versions of these packages.

Ack... finally figured out this is stopping me, too.

@BrennanConroy looks like this API (StandardFormat) was added in .NET Core 3.0, so it might be an issue that is resolved now that we have a netstandard2.0 JSON package. Can you take a quick check to see if that's the case?

@BrennanConroy you found a Xamarin issue tracking a similar problem. It looks like they are actively working on it. Can you link it here for our tracking purposes?

Issue is still there with the binary package.

looks like this API (StandardFormat) was added in .NET Core 3.0

StandardFormat is in netstandard1.1 I believe, so that shouldn't be an issue.

@BrennanConroy can you make sure there's a Xamarin issue tracking this (file one if not) and link it here? I'll ping our contacts again :).

There wasn't an issue, but there is a PR that's been merged https://github.com/mono/mono/pull/14344

Awesome, so the issue has been identified and fixed in Mono. Closing this bug.

Acceptance checklist (check one item)

  • [ ] We decided not to take this fix.
  • [ ] The fix is tests-only.
  • [x] The fix contains product changes (check all items below).

    • [x] Relevant XML documentation comments for new public APIs are present.

    • [x] Narrative docs (docs.microsoft.com) are updated. (check one item below)



      • [ ] The change requires a new article. An issue with an outline has been filed here: [ISSUE LINK]


      • [ ] The change requires a change to an existing article. A docs PR with these changes is linked here: [PR LINK]


      • [x] The change requires no docs changes.



    • [x] Verification has been completed. (check one item below)



      • [ ] The change is in the shared framework and was verified against the following versions





        • SDK installer: [VERSION]



        • ASP.NET Core Runtime: [VERSION]



        • .NET Core Runtime: [VERSION]





      • [ ] The change is in an OOB NuGet/NPM/JAR package and was verified against the following version of that package: [PACKAGE ID] [VERSION]


      • [x] The change is in Xamarin/Mono: [16.2.0.63 (d16-2@559c0f212)]



Was this page helpful?
0 / 5 - 0 ratings