6
votes

I'm trying to use mono to build a C# application for linux. But it seems that Dictionary<> and List<> are not available? I can't find any solution for this problem and I find it kind a strange because those two are pretty basic in my opinion...

this is the test code

using System.Collections.Generic;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("TESTTEST");
            List<string> s = new List<string>();
            Console.Read();
        }
    }
}

And this is the result in the console screen:

WARNING: The runtime version supported by this application is unavailable. Using default runtime: v1.1.4322

** (Test.exe:3152): WARNING **: The class System.Collections.Generic.List`1 coul d not be loaded, used in mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyTo ken=b77a5c561934e089

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Colle ctions.Generic.List`1' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral , PublicKeyToken=b77a5c561934e089'. Druk op een toets om door te gaan. . .

2
Well, version 1.1 doesn't really have generics...user541686
You need to be using at least runtime version 2.0 for the System.Collections.Generic namespace.Task
The latest stable version of Mono is here: go-mono.com/mono-downloads/download.html. Compatibility guide is here: mono-project.com/CompatibilityD'Arcy Rittich

2 Answers

8
votes

This is the problem:

Using default runtime: v1.1.4322

You want to use a 2.0 runtime or higher.

My guess is that you're compiling with mcs - try using gmcs or dmcs instead. gmcs targets 2.0, and dmcs targets 4.0. See this documentation for more details.

EDIT: Ah, this looks like it's an execution-time issue, not a compile-time issue. Which version of Mono are you using? I suspect it's trying to find 4.0, but failing... Are you actually running code you've already built on Windows?

Try installing the latest version of Mono; if that still fails, see if you can work out which runtimes have been installed.

If none of this helps, please give more details (such as which version of Mono you have installed).

0
votes

Upgrade to Mono 2.10. It provides the 4.0 class libraries and no longer ships the obsolete 1.1 profile.