sestoft / C5

C5 generic collection library for C#/.NET
http://www.itu.dk/research/c5/
MIT License
1.03k stars 181 forks source link

NuGet package does not work in mono 2.10.8.1 #18

Closed LHCGreg closed 10 years ago

LHCGreg commented 10 years ago

The C5 NuGet package does not work in mono 2.10.8.1. When I run the following test program:

using System;

namespace C5Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello world 1");
            C5.HashSet<int> x = new C5.HashSet<int>();
            Console.WriteLine ("Hello World 2");
            Console.ReadLine();
        }
    }
}

on mono 2.10.8.1 referencing C5 2.2.4881.16939, I get:

greg@Kubuntu:~/dev/MyMediaLite/src/C5Test/bin/Debug$ mono C5Test.exe
Could not load signature of C5.ICollectionValue`1[T]:Exists due to: 
Could not load signature of C5.ICollectionValue`1[T]:Exists due to: 

Unhandled Exception: System.TypeLoadException: A type load exception has occurred.
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.                                                                
greg@Kubuntu:~/dev/MyMediaLite/src/C5Test/bin/Debug$ mono C5Test.exe            
Could not load signature of C5.ICollectionValue`1[T]:Exists due to:             
Could not load signature of C5.ICollectionValue`1[T]:Exists due to: 

Unhandled Exception: System.TypeLoadException: A type load exception has occurred.
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.

When referencing the latest a version built from the latest git, I get:

greg@Kubuntu:~/dev/MyMediaLite/src/C5Test/bin/Debug$ mono C5Test.exe
Hello world 1
Missing method FirstOrDefault in assembly /home/greg/dev/MyMediaLite/src/C5Test/bin/Debug/C5.dll, type System.Linq.Enumerable

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies.
File name: 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'
  at C5.HashSet`1[System.Int32]..ctor () [0x00000] in <filename unknown>:0 
  at C5Test.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies.
File name: 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'
  at C5.HashSet`1[System.Int32]..ctor () [0x00000] in <filename unknown>:0 
  at C5Test.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 

If I edit the C5 .csproj and replace

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />

with

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

to make it a non-PCL project and recompile and have my test program reference the resulting dll, the test program works as expected.

I get the same results with mono 2.10.8 on Windows. If I use mono 3.0.10 on Windows instead, everything works.

This all leads me to believe that mono does not support PCL libraries until somewhere between 2.10.8.1 and 3.0.10. Ubuntu 13.10 Saucy Salamander comes out in 4 days and is still on mono 2.10.8.1.

Could C5 offer a non-PCL net40 build in the NuGet package or a separate non-PCL package or something? I am attempting to package MyMediaLite for NuGet. I switched MyMediaLite from storing dependencies in a lib folder to using NuGet packages so that it can declare dependencies, which involved upgrading C5 because the version MyMediaLite previously used is older than the oldest C5 Nuget package.

Support for MyMediaLite on Linux is a priority, especially because the primary developer works in Linux, and we cannot realistically claim support for Linux if it does not work on the latest version of the most popular distro. I'd like to avoid creating an unofficial non-PCL C5 package just so MyMediaLite can depend on it or bundling a non-PCL C5 inside the MyMediaLite package if possible.