相关文章推荐
深沉的书包  ·  Nodejs ...·  1 年前    · 
老实的刺猬  ·  sql ...·  1 年前    · 

After create a new project using VS 16.10 -> New .NET 5 MVC ASP project.

With making any modification I opened _Layout.cshtml and I get a bunch of errors like,
CS0234 The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I also get the same error for "Security", "UI", "Webpages" and more.

I've loaded the latest stable release of the .NET 5 32/64 bit, no effect, same error.

Both Microsoft.AspNetCore.App and Microsoft.NetCore.App are in the framework section of the dependencies.

The project will compile and run, but since Razor isn't resolving namespaces correctly 99% of the Intellisense lookups fail when I try to add code to the page.

_ViewImports.cshtml looks like this:

@using WebApplication1
@using WebApplication1.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

I tried adding @using Microsoft.AspNetCore.Mvc to the ViewImports, no effect. I know I'm missing a reference somewhere, but I can't figure out which and where.

Thanks for your help

Found the problem, originally VS 2019 was installed without ASP.NET and .NET Cross-Platform Development selected. Only .NET Desktop Development was selected. I created my ASP.NET projects without the proper modules installed. After noticing this I went back installed both missing modules however that did not fix the issue. Some linkages in the backend of VS 2019 weren't being made.

Final solution - reinstall VS 2019 with correct modules from the start (didn't try repair first). Now all the helpers, code-complete, Intellicode, it all works.

Yes, I'm seeing that now. I really wish MS never used v5 for .NET 5 cause all I get doing searches is results for MVC v5 not ASP.NET Core running off .NET5, so mass confusion!

However that still doesn't explain all these errors, keep in mind this is a net project from the VS templates, no changes.

101788-error.png