开发者

Mono C# don't recognise List and Dictionary?

开发者 https://www.devze.com 2023-03-14 16:12 出处:网络
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

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, PublicK开发者_运维百科eyTo 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. . .


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消