Not enough storage is available for `Console.ReadLine`.`

console, memory, readline, service

Solution

This is a service, and its output is likely set to Windows Application, change the output to Console Application and this should go away.

Problem

I am using a dual service/console model to test a service of mine. The code in the spotlight is: ``` static void Main(string[] args) { // Seems important to use the same service instance, regardless of debug or runtime. var service = new HostService(); service.EventLog.EntryWritten += EventLogEntryWritten; if (Environment.UserInteractive) { service.OnStart(args); Console.WriteLine("Host Service is running. Press any key to terminate."); Console.ReadLine(); service.OnStop(); } else { var servicesToRun = new ServiceBase[] { service }; Run(servicesToRun); } } ``` When I run the app under the debugger, using F5, on the line `Console.ReadLine();` I get a `System.IO.IOException`, with "Not enough storage is available to process this command." The only purpose of the `ReadLine` is to wait until someone presses a key to end the app, so I can't imagine where the data is coming from that needs so much storage.

Original source