I'm migrating from ASP.NET Core 1.x to v2.0 with the help of following post on docs.microsoft: https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/
I'm almost done with all the changes mentioned in that post. But there is one error that is causing troubles.
Here is my Program.cs file:
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
namespace MeridiaCoreAPI
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostContext, config) =>
{
// delete all default configuration providers
config.Sources.Clear();
config.AddJsonFile("myconfig.json", optional: true);
})
.Build();
}
}
And here is the error message:
Suppression State
Error CS0103 The name 'WebHost' does not exist in the current context
Any solution, workaround or hint would be highly appreciated. Thanks.
WebHost
class resides Microsoft.AspNetCore
assembly that comes with Microsoft.AspNetCore.All
NuGet package. So to fix you problem install this NuGet package and add following using
directive to your source file:
using Microsoft.AspNetCore;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With