runtime: System.Text.Json: Method not found System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8 stil happens in NuGet 5.0.0 ans 5.0.1

Still happens with:

  • Xamarin.iOS 14.14.2.5
  • and: System.Text.Json Nuget 5.0.0 and 5.0.1

Background info, because this was discussed in another thread.

Related: #1460 #31066 #31326

=== Visual Studio Community 2019 for Mac ===

Version 8.9.2 (build 0)
Installation UUID: 5b6201d9-6c1b-4904-a5a7-463b3da00b5a
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 612000125

=== Mono Framework MDK ===

Runtime:
	Mono 6.12.0.125 (2020-02/8c552e98bd6) (64-bit)
	Package version: 612000125

=== Roslyn (Language Service) ===

3.9.0-6.21152.10+c10f884b30737542ddd84ca889a4aad9281ce210

=== NuGet ===

Version: 5.8.0.6860

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.201/Sdks
SDK Versions:
	5.0.201
	3.1.407
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	5.0.4
	3.1.13

=== .NET Core 3.1 SDK ===

SDK: 3.1.407

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin Designer ===

Version: 16.9.0.316
Hash: 2241b204a
Branch: tags/vsm-rel/d16.9-4540908
Build date: 2021-03-10 22:18:10 UTC

=== Apple Developer Tools ===

Xcode 12.4 (17801)
Build 12D4e

=== Xamarin.Mac ===

Version: 7.8.2.5 (Visual Studio Community)
Hash: 3836759d4
Branch: d16-9
Build date: 2021-02-10 17:56:43-0500

=== Xamarin.iOS ===

Version: 14.14.2.5 (Visual Studio Community)
Hash: 3836759d4
Branch: d16-9
Build date: 2021-02-10 17:56:44-0500

=== Xamarin.Android ===

Version: 11.2.2.1 (Visual Studio Community)
Commit: xamarin-android/d16-9/877f572
Android SDK: /Users/jjaehrig/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 30.0.2

Build Information: 
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@54f8c24
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.34.1@daff8f4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@d210f11

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/jjaehrig/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.9.0.22
Hash: a391de2
Branch: remotes/origin/d16-9
Build date: 2021-03-05 19:52:30 UTC

=== Android Device Manager ===

Version: 16.9.0.17
Hash: fc2b3db
Branch: remotes/origin/d16-9
Build date: 2021-03-05 19:52:54 UTC

=== Build Information ===

Release ID: 809020000
Git revision: a69906fb0095d046b113a63419c9af3034ce104e
Build date: 2021-03-11 14:01:37-05
Build branch: release-8.9
Xamarin extensions: a69906fb0095d046b113a63419c9af3034ce104e

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.3.0 Darwin Kernel Version 20.3.0
    Thu Jan 21 00:06:51 PST 2021
    root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 x86_64

https://gist.github.com/juwens/d04e750ac0ad352f085da571b6a5482f

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@juwens we understand what’s going on and @filipnavara’s fix should address this.

One thing that seems to happen (occured for me when I tried to reproduce this) was that Xamarin’s ImplicitlyExpandDesignTimeFacades was not running and adding System.Memory to the build. You could workaround this by either adding <Reference Include="System.Memory" /> (what should happen after the fix) or by explicitly setting <_HasReferenceToSystemRuntime>true</_HasReferenceToSystemRuntime> property. I wasn’t sure why Xamarin’s ImplicitlyExpandDesignTimeFacades target wasn’t running for me, as I would have expected it here. THat might be something to look at @filipnavara

The triggering combination is usually a library that targets netstandard2.0 and references NuGet package System.Memory. This library can be a local one or a NuGet one. Once you include this library from Xamarin.Mac/iOS project it incorrectly overrides the built-in System.Memory.dll (version 4.0.99.0) with the one from the NuGet (version 4.0.1.1). The one from the NuGet is not meant to be used with Xamarin and causes errors at runtime for certain usage (but not always, some methods are self contained).

It’s exactly the same error as the ones linked from https://github.com/xamarin/xamarin-macios/pull/10928. I do have a repro app, several of them in fact.

Actually, the version should be 4.5.4 (the highest version in NuGet; possibly referenced from other NuGets):

<PackageReference Include="System.Memory" Version="4.5.4" IncludeAssets="None" />