'Xamarin Forms Release Problem: Mono.Linker.MarkException: Error processing method: 'System.String Microsoft.Net.Http.Headers.DateTimeFormatter
I'm kinda new to xamarin. I got this error when I'm switching from debug mode to release mode, I search everywhere but I got no answer.
Severity Code Description Project File Line Suppression State
Error Mono.Linker.MarkException: Error processing method: 'System.String Microsoft.Net.Http.Headers.DateTimeFormatter::ToRfc1123String(System.DateTimeOffset,System.Boolean)' in assembly: 'Microsoft.Net.Http.Headers.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve Microsoft.Extensions.Primitives.InplaceStringBuilder
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/builder/azdo/_work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17"
Solution 1:[1]
Trevor answer worked for me, but there is alternative solution.
I've noticed that this missing class Microsoft.Extensions.Primitives.DateTimeFormatter was removed from Microsoft.Extensions.Primitives dll in version 4.0. Some of dependencies to my project required version >=3.2 and some >=5.0. I guess linker chosen to link higher 5.0 version so the other dependency failed to find removed class.
Solution is to update all dependencies so their dependencies uses versions of Microsoft.Extensions.Primitives >=5.0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jakub C |
