加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

单声道C#不识别列表和字典?

发布时间:2020-12-15 08:16:59 所属栏目:百科 来源:网络整理
导读:我正在尝试使用mono来为 linux构建一个C#应用程序.但似乎字典和列表不可用?我找不到任何解决这个问题的方法,我觉得这很奇怪,因为在我看来这两个是非常基本的… 这是测试代码 使用System.Collections.Generic; namespace Test{ class Program { static void
我正在尝试使用mono来为 linux构建一个C#应用程序.但似乎字典<>和列表<>不可用?我找不到任何解决这个问题的方法,我觉得这很奇怪,因为在我看来这两个是非常基本的…

这是测试代码

使用System.Collections.Generic;

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

这是控制台屏幕中的结果:

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

解决方法

这就是问题:

Using default runtime: v1.1.4322

您想要使用2.0运行时或更高版本.

我的猜测是你用mcs编译 – 尝试使用gmcs或dmcs. gmcs定位2.0,dmcs定位4.0.有关详细信息,请参见this documentation.

编辑:啊,这看起来像是一个执行时问题,而不是编译时问题.您使用的是哪个版本的Mono?我怀疑它正试图找到4.0,但是失败了……你实际上是在运行已经在Windows上构建的代码吗?

尝试安装最新版本的Mono;如果仍然失败,请查看是否可以确定已安装的运行时.

如果这些都没有帮助,请提供更多详细信息(例如您安装的Mono版本).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读