Search code examples
c#blazor-server-sidevisual-studio-2022

Blazor: The type or namespace name 'Components' does not exist in the namespace


I'm trying out blazor but I find myself stuck at the creation of a project. Creating a project succeeds but it doesn't build saying:

The type or namespace name 'Components' does not exist in the namespace

I tried creating other projects multiple times, moving the content of Component folder into a new one, clean and rebuild but nothing seems to work. I tried looking around but I haven't found anything that could help me... What am I doing wrong here?

enter image description here


Solution

  • I just ran into a similar error and I believe it is related to the analyzer warning you have above your error message.

    There is a thread here about that warning. How to fix "The analyzer assembly references version '4.7.0.0' of the compiler, which is newer than the currently running version '4.6.0.0'."

    Using the global.json file did not work for me, but its worth a try. I fixed the error by upgrading the version of Visual Studio 2022 I had installed on the machine. The update was to version 17.9.6, and after a clean I was able to build successfully.