CS0234 errors on all views after creating new .NET ASP MVC project

Jonathan Jones 96 Reputation points
2021-06-02T22:19:20.827+00:00

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

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

Answer accepted by question author
  1. Jonathan Jones 96 Reputation points
    2021-06-03T12:47:13.623+00:00

    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jonathan Jones 96 Reputation points
    2021-06-03T02:04:58.023+00:00

    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

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.