The name "WebHost" does not exist
See original GitHub issueDescribe the bug
I get the following error: The name ‘WebHost’ does not exist in the current context. As I can see the WebHost
To Reproduce
I would like to create a WebApi project using .Net Core 2.2.0. I’m using the scaffolded solution proposed from Visual Studio.
Program.cs (which I see is the same as the doc):
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
Throws the following error
VS Community 15.9.4 NetCore 2.2.101
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
The name WebHost does not exists in current context
WebHost class resides Microsoft.AspNetCore assembly that comes with Microsoft.AspNetCore.All NuGet package. So to fix you problem install ...
Read more >[Fix]-The name WebHost does not exists in current context
WebHost class resides Microsoft.AspNetCore assembly that comes with Microsoft.AspNetCore.All NuGet package. So to fix you problem install this NuGet package ...
Read more >C# – The name WebHost does not exists in current context
C# – The name WebHost does not exists in current context .net-coreasp.net-coreasp.net-core-2.0c++. I'm migrating from ASP.NET Core 1.x to v2.0 with the help ......
Read more >ASP.NET Core Web Host
Learn about Web Host in ASP.NET Core, which is responsible for app startup and lifetime management.
Read more >Error: "The web host domain.xyz does not exist"
This guide is for you if you get the error The web host does not exist while visiting your site's address. Origin. This...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok I added manually the line:
<PackageReference Include="Microsoft.AspNetCore.App" />
to the .csproj file of the project. Then I also noticed that for new application scaffolded by vs studio 2017 15.9.4 , the .csproj also adds in PropertyGroup:
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Rebuilded, and then now no more issues
Looks like it might be a resharper issue. Try updating reaharper