C#没有足够的存储空间可用于在Console.ReadLine()上处理此命令

时间:2014-11-19 13:20:26

标签: c# .net .net-4.5

这是我的代码

static void Main()
        {
            /*
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                new OpenTableImporter() 
            };
            ServiceBase.Run(ServicesToRun);*/
            XMLReader x = new XMLReader(new LogCustome());
            Console.ReadLine();
        }

我得到了:

Not enough storage is available to process this command.

上的

Console.ReadLine() 你可以帮忙吗?

更新1

如你所见,班级LogCustome几乎是空的:

class LogCustome
    {
        public void logStartService() { }

        public void logStopService() { }
    }

UPDATE2

即使代码如此简单:

static void Main()
        {
            /*
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                new OpenTableImporter() 
            };
            ServiceBase.Run(ServicesToRun);*/
            //XMLReader x = new XMLReader(new LogCustome());
            Console.ReadLine();
        }

我仍然有例外

2 个答案:

答案 0 :(得分:2)

可能在项目属性上(因为您将其创建为服务),输出类型是Windows应用程序,将其更改为控制台应用程序,它将按预期工作。

答案 1 :(得分:0)

您尝试阅读超过254个字符的数据量是多少?

参见:
How to read very long input from console in C#?
Console.ReadLine() max length?