MTOUCH: error MT2001: Could not link assemblies. Reason: Object reference not set to an instance of

SimonHSimonH GBUniversity ✭✭

Hi guys

I've been unable to run AdHoc builds (with SDK linking) to produce an IPA since using the Cycle8/10.x iOS tooling due to the following build error:

MTOUCH: error MT2001: Could not link assemblies. Reason: Object reference not set to an instance of an object
        --- inner exception
        System.NullReferenceException: Object reference not set to an instance of an object
          at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessIsDirectBinding (Mono.Cecil.MethodDefinition caller, Mono.Cecil.Cil.Instruction ins) [0x00020] in <cb05882b2885456b977d8aad316be58c>:0 
          at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessCalls (Mono.Cecil.MethodDefinition caller, System.Int32 i) [0x00308] in <cb05882b2885456b977d8aad316be58c>:0 
          at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00045] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Linker.CoreOptimizeGeneratedCode.ProcessMethods (System.Collections.Generic.IEnumerable`1[T] c, System.Boolean extensions) [0x0003a] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Linker.CoreOptimizeGeneratedCode.ProcessType (Mono.Cecil.TypeDefinition type) [0x0005a] in <cb05882b2885456b977d8aad316be58c>:0 
          at MonoTouch.Tuner.OptimizeGeneratedCodeSubStep.ProcessType (Mono.Cecil.TypeDefinition type) [0x00018] in <cb05882b2885456b977d8aad316be58c>:0 
          at Mono.Tuner.SubStepDispatcher.DispatchType (Mono.Cecil.TypeDefinition type) [0x00032] in <cb05882b2885456b977d8aad316be58c>:0 
          at Mono.Tuner.SubStepDispatcher.BrowseTypes (System.Collections.ICollection types) [0x00018] in <cb05882b2885456b977d8aad316be58c>:0 
          at Mono.Tuner.SubStepDispatcher.BrowseAssemblies (System.Collections.Generic.IEnumerable`1[T] assemblies) [0x0004d] in <cb05882b2885456b977d8aad316be58c>:0 
          at Mono.Tuner.SubStepDispatcher.Process (Mono.Linker.LinkContext context) [0x0000e] in <cb05882b2885456b977d8aad316be58c>:0 
          at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00023] in <cb05882b2885456b977d8aad316be58c>:0 
          at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x000a5] in <cb05882b2885456b977d8aad316be58c>:0 
        ---
          at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x0014f] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Target.LinkAssemblies (System.String main, System.Collections.Generic.List`1[System.String]& assemblies, System.String output_dir, MonoTouch.Tuner.MonoTouchLinkContext& link_context) [0x00236] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Target.ManagedLink () [0x003a6] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Target.ProcessAssemblies () [0x000e4] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Application.BuildApp () [0x0002f] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Application.Build () [0x00053] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x01c73] in <cb05882b2885456b977d8aad316be58c>:0 
          at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000c] in <cb05882b2885456b977d8aad316be58c>:0 
    Task "MTouch" execution -- FAILED
    Done building target "_CompileToNative" in project "/Users/simonh/Documents/<path to project>/Ucl.iOS/Ucl.iOS.csproj".-- FAILED

If I revert to the previous stable Xamarin tooling everything is ok. Also if I disable all linking the problem goes away. The above is after passing -v -v -v -v to mtouch and happens if I'm building in Xamarin Studio on my Mac or from Visual Studio on my PC. I'd like to be able to provide more information to help figure this out and potentially create a bug report, but I'm a bit stuck with how to proceed here - there's not much to go on with this error. I've seen similar issues come up on the bug tracker but none of the suggested fixes/workarounds have helped here. I've also just updated to the latest service release for C8 (which should fix a similar issue) but no change.

Any help would be appreciated!

Thanks,

Simon

Tagged:

Posts

  • SimonHSimonH GBUniversity ✭✭

    Any ideas?

  • mhdmaktabimhdmaktabi Member ✭✭

    I'm unable to compile my Xamarin.iOS project. This project was recently migrated from .NET Standard 1.4 to a .NET Standard 2 project in VS2017 on Windows connect to the Mac Agent.

    I'm getting this error:

    Error: Could not link assemblies. Reason: Error while processing references of 'Clients.iOS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

    This is part of the Build log:

    warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file.

    Consider app.config remapping of assembly "System.Runtime, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "4.0.0.0" to Version "4.0.20.0" [] to solve conflict and get rid of warning.rning.

    (1,1): error: Xamarin.FFImageLoading package not found for versions [2.2.20, ] on netstandard1.4

Sign In or Register to comment.