azure-service-bus-dotnet
azure-service-bus-dotnet copied to clipboard
Xamarin Linker issue after upgrading to Nuget 3.0.1.16
Actual Behavior
- 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.
- 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
- 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.
- 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.
@sameertotey Do you have a solution in mind?
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.
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 ?
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'
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
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 1[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.List
1[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.IEnumerable
1[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.<BuildAll>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.Action
1[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
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?
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
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
Using the TaskyPortable project as a baseline, I'm able to reproduce this problem:
- Clone https://github.com/xamarin/mobile-samples
- Load TaskyPortable.sln into VS for Windows v15.9.4.
- Add a new .NET Standard 2.0 project to the solution named, "TaskyPortableStandardLibrary".
- Recreate all the classes from the TaskyPortableLibrary, and add them to the new TaskyPortableStandardLibrary project.
- Update project references from iOS/Android projects to use the new TaskyPortableStandardLibrary project instead.
- Add the Microsoft.Azure.EventHubs v2.2.1 package to the TaskyPortableStandardLibrary.
- Add some EventHubs code to TaskyPortableStandardLibrary.
- Add some code to the iOS project that uses the new EventHubs functionality you implemented in the last step.
- Add the Microsoft.Azure.EventHubs v2.2.1 package to the iOS project.
- Build iOS project.
I found that the issue was caused by two bad reference paths that were added to my iOS projects:
- TaskyPortable\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.8\lib\Xamarin.iOS10\Microsoft.IdentityModel.Clients.ActiveDirectory.dll
- TaskyPortable\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.8\lib\Xamarin.iOS10\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll
I found through experimentation (editing the csproj by hand) that the Xamarin.iOS10 folder was wrong. It should use the netstandard1.3 folder instead. And now the linker is successful. Here are the new paths that I use:
- TaskyPortable\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.8\lib\netstandard1.3\Microsoft.IdentityModel.Clients.ActiveDirectory.dll
- TaskyPortable\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.8\lib\netstandard1.3\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll