I tried this simple ASP.net 5 Console Application on both Windows (.NET 4.5.1) and Linux (Mono 4.0.1), both times with the same result.
Note: I called it an ASP.net 5 Console Application because that is what is was called in Visual Studio up to RC. Now it is called Console Application (Package), but it still uses DNX from https://github.com/aspnet/dnx :)
My Program.cs
:
using System;
using System.Threading.Tasks;
namespace ConsoleApplication
{
public class Program
{
public async void Main(String[] args)
{
#if DNX451
AppDomain.CurrentDomain.UnhandledException +=
(s, e) => Console.WriteLine(e);
#endif
try
{
await Task.Delay(1000);
Console.WriteLine("After Task.Delay");
}
finally
{
Console.WriteLine("Inside Finally");
}
}
}
}
My project.json
:
{
"version": "1.0.0-*",
"dependencies": {},
"commands": {
"ConsoleApplication": "ConsoleApplication"
},
"frameworks": {
"dnx451": {}
}
}
When running with either 1.0.0-beta4 CLR
or 1.0.0-beta5-11904 CLR
, the command dnx . ConsoleApplication
prints nothing. The program exits with status code 0 as soon as it encounters the Task.Delay
. Even the finally block is never executed.
I couldn't test .NET Core 5.0 because dnu restore
says everything is OK, but the packages can't be located by the runtime. Oh well...
Does anybody have the same problems with async/await and DNX? Or spot some error I made?