Answers
What is a vNext console application?
It's a console application that runs within the new .NET runtime environment (DNX).
Why the restrictions and what are the uses of them?
The restrictions occur because you are targeting .NET Core (dnxcore50
) instead of (or in addition to) the full .NET Framework (dnx451
.) The use of those restrictions, as far as I know, is to allow cross-compatibility with a lot of different operating systems. That is, .NET Core has less functionality than the full framework does, because it is easier to be compatible with many systems that way. Overtime, those restrictions may fall away as more in made fully cross platform.
The default template does not specify Main() as static.
DNX
comes with Microsoft.Framework.ApplicationHost
. This default application host "knows how to find a public void Main
method. This is the entry point used to set up the ASP.NET hosting layer..." It also still knows how to find the traditional static void Main
method. An advantage of an instance Main
method is that it lets us ask the runtime environment to inject services into our application.
Many assemblies such as System.CodeDom and System.Net are not available. Many methods such as System.Console.ReadKey cannot be used.
System.Console.ReadKey
is available in dnx451
but not in dnxcore50
. That's also true for System.Net
the last time I checked. So, if you want to use those, make sure to target dnx451
instead of dnxcore50
.
Want to remove the restrictions? Just delete the dnxcore50
entry from your project.json
file. Then you'll only be targeting the full framework without restrictions.
See Also
https://msdn.microsoft.com/en-us/magazine/dn913182.aspx
'Console' does not contain a definition for 'ReadKey' in asp.net 5 console App
Using System.Net.Mail in ASP NET MVC 6 project