What is a vNext console application?

I installed Visual Studio 2015 RC to try out ASP.Net vNext templates. In the "Web" section, I noticed a console application that displays as

enter image description here

I decided that I would argue with him, and I found some interesting points:

  • The default template does not specify Main() as static .
  • Many assemblies, such as System.CodeDom and System.Net , are not available.
  • Many methods cannot be used, such as System.Console.ReadKey .

What are these vNext console applications? Why are limitations and what are their uses?

+5
source share
3 answers

The answers

What is a vNext console application?

This is a console application that runs in the .NET environment of the .NET runtime (DNX).

Why are limitations and what are their uses?

Limitations arise because you target the .NET Core ( dnxcore50 ) instead of (or in addition) the full .NET Framework ( dnx451 .) Using these limitations, as far as I know, is to provide cross-compatibility with many different operating systems. That is, .NET Core has less functionality than in the full structure, because it is easier to be compatible with many systems. Overtime, these restrictions may disappear, as there is more in a 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 the public void Main method. This is the entry point used to configure the ASP.NET hosting level ...” He also still knows how to find the traditional static void Main method. The advantage of the Main instance method is that it allows us to query the runtime for implementing services in 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 . This is also true for System.Net the last time I checked. Therefore, if you want to use them, make sure you select dnx451 instead of dnxcore50 .

Want to remove restrictions? Just delete the dnxcore50 entry from your project.json file. Then you will only focus on the full frame without any 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 application

Using System.Net.Mail in an ASP NET MVC 6 Project

+6
source

These console applications use the new environment . NET (DNX, formerly KRE). It includes a new project system and allows you to customize various versions of the CLR .

One of these versions is CoreCLR, which is a thin version of .NET. This version is modular, and its libraries are distributed as a bunch of NuGet packages. You may need to include some additional packages when configuring the .NET Core component (dependencies in the project.json file).

However, some of the restrictions may arise due to the fact that not all APIs are already ported to .NET Core or because they will not be there, since the surface of the API is smaller on .NET Core.
+3
source

I am slowly moving to a new runtime and updating this post with the appropriate links.

Microsoft.Framework.Runtime.Sources.EntryPointExecutor-> TryGetEntryPoint () Has a piece of code that highlights the program class and its main function

0
source

All Articles