question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The name "WebHost" does not exist

See original GitHub issue

Describe 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

image

VS Community 15.9.4 NetCore 2.2.101

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alessandroroscommented, Dec 20, 2018

I tried but it doesn’t work for me. Just to repeat your steps:

  1. Change Target Framework to 2.1
  2. Save
  3. Rechange Target Framework to 2.2
  4. Save and Rebuild Projects

Correct?

Yes, steps are correct. But check if in csproj file something has been change after 1 and 3 steps. And make sure that Microsoft.AspNetCore.App (2.2.0) dll is added to the project. answ

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

1reaction
davidfowlcommented, Dec 13, 2018

Looks like it might be a resharper issue. Try updating reaharper

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found