Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

The "LinkAssemblies" task failed unexpectedly error while building the application

EinsAntonyEinsAntony USMember ✭✭
edited September 2017 in Xamarin.Forms

Hi,

I'm getting the below error while building the application using linking SDK assemblies option and with out shared runtime (as shared run time causing error while release the application.)


Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void System.Net.Http.HttpClientHandler/c__async0::MoveNext()' in assembly: 'System.Net.Http.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Net.WebHeaderCollection::AddValue(System.String,System.String)
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
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.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() D:\Program Files\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1577

if shared runtime option is unchecked and link option none httpclient.GetStringAsync() method will raise the following error
Method 'System.Net.WebHeaderCollection.AddValue' not found.

but application is working fine when the shared runtime option is ticked and 'SDK assemblies only' link option selected in the android options tab.
I could find lot of similar threads but couldn't find any solution for this one.

Thanks,
Eins

Best Answer

  • EinsAntonyEinsAntony USMember ✭✭
    Accepted Answer

    Solved.
    System.Net.Http.dll was referred from a different location in the android project references. Changing that fixed my issue.

    Thanks,
    EIns

Answers

  • EinsAntonyEinsAntony USMember ✭✭
    Accepted Answer

    Solved.
    System.Net.Http.dll was referred from a different location in the android project references. Changing that fixed my issue.

    Thanks,
    EIns

  • GeethaThangamGeethaThangam USMember ✭✭

    I changed Linker properties from "SDK Assemblies only" to "None" and it worked in my case.

  • mac121mac121 Member ✭✭✭
    edited February 2019

    @GeethaThangam

    Check Linker Behavior in https://docs.microsoft.com/en-us/xamarin/android/deploy-test/linker#linker-behavior

    The Don't Link option (None) turns off the linker; the above "Release without Linking" application size example used this behavior. This is useful for troubleshooting runtime failures, to see if the linker is responsible. This setting is not usually recommended for production builds.

  • JoshuaTantonJoshuaTanton USMember ✭✭

    @EinsAntony How did you figure out how to fix it? My issue is with Plugin.MediaManager.dll I installed this via nuget. I've tried uninstalling and reinstalling and the problem persists. What did you do to change the reference?

  • MadhavadityaMadhavaditya Member ✭✭

    Hi I have same scenario

    Severity Code Description Project File Line Suppression State
    Error The "LinkAssemblies" task failed unexpectedly.
    Mono.Linker.MarkException: Error processing method: 'System.Void Door.Droid.MainActivity::OnCreate(Android.OS.Bundle)' in assembly: 'Door.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Door.App::.ctor()
    at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
    at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
    at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
    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 MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
    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.Execute()
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Door.Android

    What is the solution in this error

  • asrarehsanasrarehsan Member

    @EinsAntony said:
    Solved.
    System.Net.Http.dll was referred from a different location in the android project references. Changing that fixed my issue.

    Thanks,
    EIns

    Please describe how it solved, could you mention the steps to perform cause I have the same problem, thanks

Sign In or Register to comment.