Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono C# don't recognise List and Dictionary?

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. . .

like image 251
BvdVen Avatar asked Jun 21 '11 16:06

BvdVen


1 Answers

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).

like image 191
Jon Skeet Avatar answered Oct 09 '22 09:10

Jon Skeet