Compiler Error

makzrmakzr Markus KölzerUSMember
edited June 2013 in Xamarin Studio

Hey,

I'm using Xamarin Studio 4.0.8 on Mac OS 10.8. Currently I'm on the beta channel because we need some new features of Mono 3 (.NET Tasks) When compiling a iOS library I get the following compiler error. It looks like a bug in the Xamarin Studio or in Mono compiler.

Building: <...> (Debug)
Performing main compilation...
/Library/Frameworks/Mono.framework/Versions/3.0.10/bin/mcs /noconfig "/r:/Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll" -nostdlib "/out:<...>" 
    <...>

Unhandled Exception:
System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[IKVM.Reflection.TypeName,IKVM.Reflection.Type].Add (TypeName key, IKVM.Reflection.Type value) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Module.GetTypes () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[IKVM.Reflection.TypeName,IKVM.Reflection.Type].Add (TypeName key, IKVM.Reflection.Type value) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Module.GetTypes () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 



Unhandled Exception:
System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[IKVM.Reflection.TypeName,IKVM.Reflection.Type].Add (TypeName key, IKVM.Reflection.Type value) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Module.GetTypes () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[IKVM.Reflection.TypeName,IKVM.Reflection.Type].Add (TypeName key, IKVM.Reflection.Type value) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Module.GetTypes () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
Build complete -- 1 error, 0 warnings

Posts

  • MarekSafarMarekSafar Marek Safar USMember, Xamarin Team Xamurai

    That's looks like compiled bug indeed. Could you fill a bug report with the reference assembly causing this issue. You can use --mcs-debug 9 to track it down.

  • makzrmakzr Markus Kölzer USMember

    For your info: I could identify and solve the problem. We had a project with the following wildcard include statement:

    <ItemGroup>
      <Compile Include="**\*.cs" />
    </ItemGroup>
    

    In addition to that we defined:

    <ItemGroup>
        <Compile Include="Foo\Bar.cs" />
    </ItemGroup>
    

    Xamarin Studio doesn't display files that are included via wildcard, hence nobody noticed that the file was referenced twice.

    Summary: 1) The compiler exception is not very helpful. 2) Please fix the display problem in Xamarin Studio.

  • MarekSafarMarekSafar Marek Safar USMember, Xamarin Team Xamurai

    I'll add better exception but the problem was in references loading not source files. The crash should be reproducible with no source files in project.

  • makzrmakzr Markus Kölzer USMember

    Hi, thank you.

    Actually it was in the referenced project:

    Project A contained the sources and the project file described above. Project B referenced Project A. The error happend when I compiled Project B.

  • mhutchmhutch Michael Hutchinson USModerator, Xamarin Team Xamurai

    Could you please file a bug with a minimal test case attached?

Sign In or Register to comment.