0

I am having an old library written in VB.net .net 3.5 using this library as dll or project reference on Xamarin.Android project works fine with linker to "none". Problem starts if I use a linker. When I set the linker as "SDK assemblies only", I am getting the following error message.

Error Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'System.Void Microsoft.VisualBasic.MyGroupCollectionAttribute::.ctor(System.String,System.String,System.String,System.String)' (defined in assembly 'VBLibraryProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken='. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Microsoft.VisualBasic.MyGroupCollectionAttribute::.ctor(System.String,System.String,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.MarkCustomAttribute(CustomAttribute ca)
at Mono.Linker.Steps.MarkStep.MarkCustomAttributes(ICustomAttributeProvider provider) at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type) at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type) at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly) at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly) at Mono.Linker.Steps.MarkStep.Initialize() 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)

I have added AndroidLinkSkip for those libraries like below

 <AndroidLinkSkip>Microsoft.VisualBasic;Microsoft.VisualBasic.Core;VBLibraryProject</AndroidLinkSkip>

Despite that it is still failing with the same error? Project is using the latest XF 4.8 version with Android.Support libraries and target version android 9.0 minimum version 8.0

EDIT: I have tried with a linker.xml from type of LinkDescription as below but it didnt help.

<linker>   
  <assembly fullname="Microsoft.VisualBasic">
    <namespace fullname="Microsoft.VisualBasic" />
  </assembly>
  <assembly fullname="Microsoft.VisualBasic.Core">
    <namespace fullname="Microsoft.VisualBasic" />
  </assembly>
  <assembly fullname="VBLibraryProject">
Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
Emil
  • 6,411
  • 7
  • 62
  • 112

1 Answers1

0

If you need some definitions from the SDK or product assemblies then using an XML file might be your best solution (versus adding code that will ensure the linker won't eliminate what you need).

You could refer to Custom Linker Configuration

Leo Zhu
  • 15,726
  • 1
  • 7
  • 23
  • I have already tried it using linker.xml with LinkDescription type but it didnt help. please see my updated question above – Emil Oct 13 '20 at 16:34
  • It seems that there is a mismatch in versions between forwarded types in `VBLibraryProject` and `Microsoft.VisualBasic`,try to disable linking for one assembly in `AndroidLinkSkip`. – Leo Zhu Oct 14 '20 at 08:43
  • thats what i tried every possible combination of AndroidLinkSkip. I have tried each separately and both together but result doesnt change. – Emil Oct 14 '20 at 15:07
  • You may change Linking to 'None' temporarily. – Leo Zhu Oct 16 '20 at 03:12
  • it is already fine with None but for a release, i blieve that it cannot be a solution. I only would like to know this error is caused by VB library or because .net 3.5 dll is not really supported with linker. Even though AOT or startup AOT also giving error for the same library and nuget. :( – Emil Oct 16 '20 at 12:53
  • From the log information seems to be because of the VB library. – Leo Zhu Oct 20 '20 at 06:44