visual-studioblazorbuild-error

Newly created Blazor project in Visual Studio won't build


Using Visual Studio 2022 Professional, Version 17.8.6, I just created a new Blazor project and it won't build at all. When trying to build, I get the error:

error CS0246: The type or namespace name 'TVMS' could not be found.

I see similar questions on the web about the compiler not finding the App namespace. But in my case it does not find the namespace of the project itself? (TVMS is the name of the project/solution.)

What's interesting is that this error only shows as the output of the failed build, but not in the error list. What I see in the error list is the following warning:

The analyzer assembly 'C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk.Razor\source-generators\Microsoft.CodeAnalysis.Razor.Compiler.SourceGenerators.dll' references version '4.9.0.0' of the compiler, which is newer than the currently running version '4.8.0.0'.

Could this compiler version difference be a reason for the build failure? Or it's something else?


Solution

  • As answered above in the comments, the solution seemed to have been to simply update Visual Studio to the latest release. Now the alert is gone and it builds without issues. Thank you.