C# - Program does not contain a static - Main method for entry point


When working with Async method, you often bump into the following issues. Not all code are made 'async'.

There are 2 workarounds which are shown here.

public static void Main(string[] args)
{     
    MyProgram(args).RunAsync().GetAwaiter().GetResult();
}

Or with code below which does not return result (void operation)

public static void Main(string[] args)
{
    BuildWebHost(args).RunAsync().Wait();
}

If you're just going to return Task, you can do this 

 public async Task ProvisionService(RequestType requestType)
{
            return await Task.FromResult("ok");
 }


Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm