Could not link assemblies. Reason: Value cannot be null. (MT2001)

Hello there,

I'm quite new to Xamarin and since this morning I'm not able anymore to build my project, which was previously working.

I cannot say which was the Xamarin Studio version I had, but today I have updated to 6.1 (build 5441), with Mono 4.6.0 .NET runtime.
My project is a simple iOS library binding + test application.

Anyone is facing the same issue?
How can I get more info about it? I didn't find anything useful in the logs.

Thanks in advance.

Best Regards,
Daniele

Posts

  • DanieleAltomareDanieleAltomare CHMember
    edited September 2016

    This is the error log:

    MTOUCH: error MT2001: Could not link assemblies. Reason: Value cannot be null.
            Parameter name: dest
            --- inner exception
            System.ArgumentNullException: Value cannot be null.
            Parameter name: dest
              at System.IO.MemoryStream.ToArray () [0x0004c] in /private/tmp/source-mono-4.6.0/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/io/memorystream.cs:559 
              at Mono.Cecil.EmbeddedResource.GetResourceData () [0x0005a] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/EmbeddedResource.cs:88 
              at Mono.Cecil.MetadataBuilder.AddEmbeddedResource (Mono.Cecil.EmbeddedResource resource) [0x00008] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:1019 
              at Mono.Cecil.MetadataBuilder.AddResources () [0x0006a] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:983 
              at Mono.Cecil.MetadataBuilder.BuildModule () [0x00075] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:845 
              at Mono.Cecil.MetadataBuilder.BuildMetadata () [0x00002] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:823 
              at Mono.Cecil.ModuleWriter.<BuildMetadata>m__0 (Mono.Cecil.MetadataBuilder builder, Mono.Cecil.MetadataReader _) [0x00001] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:133 
              at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00033] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/ModuleDefinition.cs:827 
              at Mono.Cecil.ModuleWriter.BuildMetadata (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata) [0x00037] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:132 
              at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x000cc] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:108 
              at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x0002c] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/ModuleDefinition.cs:1021 
              at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x0000f] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/ModuleDefinition.cs:1010 
              at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00009] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyDefinition.cs:175 
              at Mono.Linker.Steps.OutputStep.OutputAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x0005d] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Mono.Linker.Steps.OutputStep.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context) [0x0002b] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00023] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x000a5] in <86a99508958c45bc8a05d21e3b49a458>:0 
            ---
              at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x0014e] in <86a99508958c45bc8a05d21e3b49a458>: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 <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Target.ManagedLink () [0x003a6] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Target.ProcessAssemblies () [0x000e4] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Application.BuildApp () [0x0002f] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Application.Build () [0x00052] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x01c6c] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000c] in <86a99508958c45bc8a05d21e3b49a458>:0 
        Task "MTouch" execution -- FAILED
    
  • Sometimes the error is the same, but the stack trace is different :confused:

    MTOUCH: error MT2001: Could not link assemblies. Reason: Value cannot be null.
            Parameter name: dst
            --- inner exception
            System.ArgumentNullException: Value cannot be null.
            Parameter name: dst
              at System.Buffer.BlockCopy (System.Array src, System.Int32 srcOffset, System.Array dst, System.Int32 dstOffset, System.Int32 count) [0x000a7] in /private/tmp/source-mono-4.6.0/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/corlib/ReferenceSources/Buffer.cs:61 
              at Mono.Cecil.PE.ByteBuffer.Grow (System.Int32 desired) [0x00022] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil.PE/ByteBuffer.cs:352 
              at Mono.Cecil.PE.ByteBuffer.WriteBytes (System.Byte[] bytes) [0x0001c] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil.PE/ByteBuffer.cs:294 
              at Mono.Cecil.Metadata.ResourceBuffer.AddResource (System.Byte[] resource) [0x00013] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil.Metadata/Buffers.cs:241 
              at Mono.Cecil.MetadataBuilder.AddEmbeddedResource (Mono.Cecil.EmbeddedResource resource) [0x0000d] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:1019 
              at Mono.Cecil.MetadataBuilder.AddResources () [0x0006a] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:983 
              at Mono.Cecil.MetadataBuilder.BuildModule () [0x00075] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:845 
              at Mono.Cecil.MetadataBuilder.BuildMetadata () [0x00002] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:823 
              at Mono.Cecil.ModuleWriter.<BuildMetadata>m__0 (Mono.Cecil.MetadataBuilder builder, Mono.Cecil.MetadataReader _) [0x00001] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:133 
              at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00033] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/ModuleDefinition.cs:827 
              at Mono.Cecil.ModuleWriter.BuildMetadata (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata) [0x00037] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:132 
              at Mono.Cecil.ModuleWriter.WriteModuleTo (Mono.Cecil.ModuleDefinition module, System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x000cc] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyWriter.cs:108 
              at Mono.Cecil.ModuleDefinition.Write (System.IO.Stream stream, Mono.Cecil.WriterParameters parameters) [0x0002c] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/ModuleDefinition.cs:1021 
              at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x0000f] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/ModuleDefinition.cs:1010 
              at Mono.Cecil.AssemblyDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00009] in /Users/builder/data/lanes/3426/6c3fee4d/source/xamarin-macios/external/cecil/Mono.Cecil/AssemblyDefinition.cs:175 
              at Mono.Linker.Steps.OutputStep.OutputAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x0005d] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Mono.Linker.Steps.OutputStep.ProcessAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00000] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Mono.Linker.Steps.BaseStep.Process (Mono.Linker.LinkContext context) [0x0002b] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00023] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x000a5] in <86a99508958c45bc8a05d21e3b49a458>:0 
            ---
              at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[System.String]& assemblies) [0x0014e] in <86a99508958c45bc8a05d21e3b49a458>: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 <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Target.ManagedLink () [0x003a6] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Target.ProcessAssemblies () [0x000e4] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Application.BuildApp () [0x0002f] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Application.Build () [0x00052] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x01c6c] in <86a99508958c45bc8a05d21e3b49a458>:0 
              at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000c] in <86a99508958c45bc8a05d21e3b49a458>:0 
        Task "MTouch" execution -- FAILED
    
  • INDYINDY USMember
  • I too am having this issue with Vs.net 2017 RC (latest released on Friday) and VS for Mac. Both will not allow linking.

  • SergioChavesSergioChaves USMember ✭✭

    In our case, after several tries, we found that the "[XamlCompilation(XamlCompilationOptions.Compile)]" diretive was causing the error. After removing that, we was able to compile, generate the IPA file and send to Store our iOS code.
    Is there any reasonable explanation to suffer with that?

  • JamesHancock.1360JamesHancock.1360 USMember ✭✭

    This works! The bug still exists however without this.

  • @SergioChaves

    Thanks... This Works for me :)

  • AriJohannessonAriJohannesson USUniversity ✭✭

    I have this same error after upgrading Xamarin. Tried to turn off Xaml Compilation as suggested without success.

  • ManojkumarMaliManojkumarMali USMember ✭✭✭

    @SergioChaves Thank you.

  • HGiritzerHGiritzer ATMember ✭✭
    edited July 2017

    Content replaced by Post below. Can't delete, sorry.

  • HGiritzerHGiritzer ATMember ✭✭
    edited July 2017

    Clean solution (get rid of all old binaries) and Linker behaviour: "Don't Link" works for me.
    XamlCompilation on or off makes no difference, the only workaround is "Don't Link" in my case.

    EDIT: Would have been too easy... "Don't Link" produces a binary that contains literally everything, and Apple complains about missing Info.plist-Keys. None of them I really need or use, but "Don't Link" takes them all.
    See also https://forums.xamarin.com/discussion/79996/apple-rejected-xforms-app.
    Trying "Link All" next, maybe this works...

  • HGiritzerHGiritzer ATMember ✭✭

    Mono.Data.Sqlite.Portable was the cause for my problem.
    See: https://forums.xamarin.com/discussion/comment/287033/#Comment_287033

  • Ashish_sharmaAshish_sharma INMember ✭✭✭

    @JamesHancock.1360 said:
    I too am having this issue with Vs.net 2017 RC (latest released on Friday) and VS for Mac. Both will not allow linking.

    Same problem i'm also facing

Sign In or Register to comment.