Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Console' does not contain a definition for 'ReadKey' in asp.net 5 console App

I am creating a Simple application in ASP.NET 5 Console in VS2015 CTP. For the below line of code

// Wait for user input
            Console.ReadKey(); 

I am getting error 'Console' does not contain a definition for 'ReadKey'. Also i am getting a Suggestion as ASP.Net 5.0-Available ASP.NET Core 5.0- Not available. ReadKey keyword is no more used ? what does that suggestion means i need to add some reference ?

like image 723
Shrivallabh Avatar asked Jun 02 '15 06:06

Shrivallabh


1 Answers

Basically, Console.ReadKey is available in the full framework, but isn't available in .NET Core. That's why it's saying it's "Available" for ASP.NET 5.0 (building against the full framework) but "Not available" for ASP.NET Core 5.0 (building against CoreCLR).

Either stop using it, or only build against the full framework - edit your project.json file to remove the "core" option from your frameworks property. (Exactly what it will be called will depend on which version of ASP.NET 5 you're using. It may be dnxcore50 for example.)

like image 182
Jon Skeet Avatar answered Oct 19 '22 08:10

Jon Skeet