New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin Linker issue after upgrading to Nuget 3.0.1.16 #472

Open
sameertotey opened this Issue May 24, 2018 · 9 comments

Comments

Projects
None yet
10 participants
@sameertotey
Copy link

sameertotey commented May 24, 2018

Actual Behavior

  1. When we upgrade the nuget package to 3.0.1.6 (from 2.0.0) we can no longer link the app binary for both Xamarin.iOS and Xamarin.Android.
  2. We receive the following error message:
    MTOUCH: Error MT2002: Failed to resolve "Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate" reference from "Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.17.2.31801, Culture=neutral, PublicKeyToken=31bf3856ad364e35" (MT2002)

Expected Behavior

  1. We expect the Xamarin linker to be able to reduce the size of the application by discarding unneeded types etc. The Xamarin linker worked fine with version 2.0.0 of the package.
  2. There is a dependency on Microsoft.Azure.Services.AppAuthentication package in the new package which in-turn references Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate which is causing the problem.

Versions

  • OS platform and version:
    Xamarin
  • .NET Version:
    .Net Standard 2.0
  • NuGet package version or commit ID:
    3.0.1.16
    We cannot install nuget 3.0.0 again because of dependency on Microsoft.Azure.Services.AppAuthentication which cannot be satisfied.
@nemakam

This comment has been minimized.

Copy link
Member

nemakam commented Jun 22, 2018

@sameertotey
Do you have a solution in mind?

@rringham

This comment has been minimized.

Copy link

rringham commented Sep 5, 2018

Having same issue with Microsoft.Azure.EventHubs v2.1.0.

The ideal solution would be for Xamarin .NET Standard solutions to be able to reference Microsoft.Azure.EventHubs and build in release mode.

@jernelson7

This comment has been minimized.

Copy link

jernelson7 commented Sep 26, 2018

Hi, what is the solution for this? Or is there a workaround? I'm trying to use the Microsoft.Azure.EventHubs 2.1 nuget in a .Netstandard 2.0 project used by Uwp and iOS apps. I'm afraid I won't be able to use this nuget, which is a major drawback. @nemakam ?

@Dave-Osborne

This comment has been minimized.

Copy link

Dave-Osborne commented Oct 12, 2018

Also experiencing this issue with Xamarin Forms, works fine with the Android build though.

UPDATE: I resolved it by setting the 'Linker behavior' option in the iOS project settings to 'Link All'

@adamhockemeyer

This comment has been minimized.

Copy link

adamhockemeyer commented Oct 24, 2018

Changing to "Link All" got the project to build for me, but then would fail when calling await queueClient.SendAsync(msg); with the message "the lazily-initialize type does not have a public parameter-less constructor". I printed out the stack trace of the message and found the issue steming from the Microsoft.Azure.Amqp namespace.

To resolve this for me I had to add the following argument in the mtouch.

--linkskip=Microsoft.Azure.Amqp

@shudson302

This comment has been minimized.

Copy link

shudson302 commented Nov 2, 2018

I am having this issue with Xamarin.IOS. I am referencing Microsoft.Azure.ServiceBus v. 3.1.1 from a class library that is .Net Standard 2.0. The Xamarin.IOS project then references the class library. Xamarin.ios is set to Dont Link

I get the following build error
Severity Code Description Project File Line Suppression State
Error Could not link assemblies. Reason: Error while processing references of 'NextIDClientiOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' NID.Client.iOS

Mono.Linker.LoadException: Error while processing references of 'NextIDClientiOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Linker.LoadException: Error while processing references of 'NID.Client.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Linker.LoadException: Error while processing references of 'NID.Client.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c'
14> at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in :0
14> at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/AssemblyResolver.cs:80
14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00009] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:210
14> --- End of inner exception stack trace ---
14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00046] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:220
14> at Mono.Linker.LinkContext.ResolveReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00024] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:254
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x0002c] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:52
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54
14> --- End of inner exception stack trace ---
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00056] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:56
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54
14> --- End of inner exception stack trace ---
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00056] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:56
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54
14> --- End of inner exception stack trace ---
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00056] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:56
14> at Mono.Linker.Steps.LoadReferencesStep.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00001] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:42
14> at Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context) [0x0002e] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/BaseStep.cs:61
14> at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x0001f] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/Pipeline.cs:127
14> at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x000e0] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Tuning.cs:80 14> --- 14> --- inner exception 14> Mono.Linker.LoadException: Error while processing references of 'NID.Client.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Linker.LoadException: Error while processing references of 'NID.Client.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' 14> at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <cf7a158ef20945e2bfed3d139c691ed5>:0 14> at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/AssemblyResolver.cs:80 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00009] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:210 14> --- End of inner exception stack trace --- 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00046] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:220 14> at Mono.Linker.LinkContext.ResolveReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00024] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:254 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x0002c] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:52 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54 14> --- End of inner exception stack trace --- 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00056] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:56 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54 14> --- End of inner exception stack trace --- 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00056] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:56 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54 14> --- 14> --- inner exception 14> Mono.Linker.LoadException: Error while processing references of 'NID.Client.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' 14> at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <cf7a158ef20945e2bfed3d139c691ed5>:0 14> at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/AssemblyResolver.cs:80 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00009] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:210 14> --- End of inner exception stack trace --- 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00046] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:220 14> at Mono.Linker.LinkContext.ResolveReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00024] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:254 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x0002c] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:52 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54 14> --- End of inner exception stack trace --- 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00056] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:56 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54 14> --- 14> --- inner exception 14> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' ---> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' 14> at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <cf7a158ef20945e2bfed3d139c691ed5>:0 14> at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/AssemblyResolver.cs:80 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00009] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:210 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00046] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:220 14> at Mono.Linker.LinkContext.ResolveReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00024] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:254 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x0002c] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:52 14> at Mono.Linker.Steps.LoadReferencesStep.ProcessReferences (Mono.Cecil.AssemblyDefinition assembly) [0x00049] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker.Steps/LoadReferencesStep.cs:54 14> --- 14> --- inner exception 14> Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.ServiceBus, Version=3.1.1.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c' 14> at Mono.Cecil.BaseAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00105] in <cf7a158ef20945e2bfed3d139c691ed5>:0 14> at Mono.Linker.AssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name, Mono.Cecil.ReaderParameters parameters) [0x00071] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/AssemblyResolver.cs:80 14> at Mono.Linker.LinkContext.Resolve (Mono.Cecil.IMetadataScope scope) [0x00009] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/linker/linker/Linker/LinkContext.cs:210 14> --- 14> at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x003ad] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Tuning.cs:122
14> at Xamarin.Bundler.Target.LinkAssemblies (System.Collections.Generic.List1[Mono.Cecil.AssemblyDefinition]& assemblies, System.String output_dir, System.Collections.Generic.IEnumerable1[T] sharedCodeTargets) [0x00256] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Target.cs:517
14> at Xamarin.Bundler.Target.ManagedLink () [0x00720] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Target.cs:664
14> at Xamarin.Bundler.Target.ProcessAssemblies () [0x000c2] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Target.cs:868
14> at Xamarin.Bundler.Application.ProcessAssemblies () [0x0002f] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Application.cs:1411
14> at Xamarin.Bundler.Application.BuildManaged () [0x00001] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Application.cs:839
14> at Xamarin.Bundler.Application+<>c.b__140_1 (Xamarin.Bundler.Application v) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Application.cs:787
14> at System.Collections.Generic.List1[T].ForEach (System.Action1[T] action) [0x00024] in <71f4e3d7d65e42b0a699d02e59766d3c>:0
14> at Xamarin.Bundler.Application.BuildAll () [0x00050] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/Application.cs:787
14> at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x00423] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/mtouch.cs:1402
14> at Xamarin.Bundler.Driver.Main (System.String[] args) [0x00015] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/tools/mtouch/mtouch.cs:934

@avodovnik

This comment has been minimized.

Copy link

avodovnik commented Nov 3, 2018

I'm running into this problem as well, after referencing the EventHub .NET standard library in a Xamarin app. However, the suggested workaround does not work, as it actually disables the plugins that are linked in the project. Has anyone found a solution/workaround to this?

@IngweLand

This comment has been minimized.

Copy link

IngweLand commented Jan 3, 2019

Half a year later - and the issue still has not been resolved.. Just got it too when upgrading EventHubs nuget for Xamarin.Forms solution to v 2.2.1

@tele-bird

This comment has been minimized.

Copy link

tele-bird commented Jan 8, 2019

Microsoft.Azure.EventHubs also has a dependency on Microsoft.Azure.Services.AppAuthentication, and so I'm having this issue using EventHub .NET standard library as well. Here is my example project: https://github.com/tele-bird/eventhub-poc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment