Scaffolding: Missing @using at Layout file

Created on 2 Oct 2019  路  8Comments  路  Source: dotnet/Scaffolding

Steps to reproduce:

Please see https://stackoverflow.com/a/58204848/3728901

Severity:       Error
Error Code:     CS0246
Description:    The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?)
Project:        foo
File:       C:\Users\donhuvy\Desktop\acc133b3\foo\obj\Debug\netcoreapp3.0\Razor\Pages\Shared\_Layout.cshtml.g.cs
Line:       455
Suppression State:  Active

Expected behavior:

Has @using at the top of file.

Actual behavior:

Compile project error.

Additional information about the project being scaffolded, such as:

Target framework(s):

.NET Core 3.0.100 , Visual Studio 2019

Package version of Microsoft.AspNetCore.App or Microsoft.AspNetCore.All (if applicable):

Package version of Microsoft.VisualStudio.Web.CodeGeneration.Design - this may be added to your project by scaffolding:

Most helpful comment

In .Net Core 3.1 I see same error.

Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?) LogicServices D:GitHubtyrchiksrcTyrchik.SiteLogicLayerLogicServicesUploadFileService.cs 15 Active

All 8 comments

@HaoK - This is already fixed right? If so, can you please resolve this bug?

In .Net Core 3.1 I see same error.

Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?) LogicServices D:GitHubtyrchiksrcTyrchik.SiteLogicLayerLogicServicesUploadFileService.cs 15 Active

@deepchoudhery can you please take a look?

The new packages for 3.1 should have the issue fixed. What is the version of the package being used currently?

In .Net 5 and ASP.NET Core 5 same error
The type or namespace name 'IWebHostEnvironment' could not be found (are you missing a using directive or an assembly reference?)

@HaoK - It is happening for me with DotNet Core version 3.1.405. Will you reopen this issue or should I create a new one?
After migration of ASP/DotNet Web App from 2.1 to 3.1

Program.cs

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost
                .CreateDefaultBuilder(args)
                .UseKestrel(options =>
                {
                    if (isDevelopment)
                    {
                        options.Listen(IPAddress.Loopback, 5001);
                        options.Listen(IPAddress.Loopback, 44301, listenOptions =>
                        {
                            listenOptions.UseHttps(Environment.GetEnvironmentVariable("LOCAL_CERT_PFX_PATH"), "develop");
                        });
                    }
                })
                .UseSerilog()
                .UseConfiguration(Configuration)
                .UseStartup<Startup>();
      }

It is not working in .Net 5. Please fix it. I'm using @using Microsoft.AspNetCore.Hosting

Was this page helpful?
0 / 5 - 0 ratings