Update - seems to be a computer problem? Even when I created a new project, same errors appear immediately. But I did not make any changes to computer.
It is a asp.net core blazor webassembly project. I have been working on it for some days. Today several namespaces went "missing".
What I have tried:
Uninstall the nuget packages and then reinstall didn't solve it.
Restart visual studio didn't help
Reboot computer didn't help
Cleared nuget cache as mentioned here didn't help.
Ran a git restore . to rollback changes didn't help.
Delete bin and obj folder then rebuild didn't help.
donet restore command didn't help
The .csproj file content is:
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<!--<RunAOTCompilation>true</RunAOTCompilation>-->
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Pages\Index.razor.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.2.0" />
<PackageReference Include="BlazorWasmAntivirusProtection" Version="1.8.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="6.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="6.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.10" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\BlazorApp.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>
</Project>
Build output error text:
Rebuild started...
Restored C:\some\path\Shared\BlazorApp.Shared.csproj (in 2 ms).
1>------ Rebuild All started: Project: BlazorApp.Shared, Configuration: Debug Any CPU ------
Restored C:\some\path\Server\BlazorApp.Server.csproj (in 87 ms).
Restored C:\some\path\Client\BlazorApp.Client.csproj (in 87 ms).
1>C:\some\path\Shared\SharedFunctions.cs(51,17,51,18): warning CS0642: Possible mistaken empty statement
1>BlazorApp.Shared -> C:\some\path\Shared\bin\Debug\net6.0\BlazorApp.Shared.dll
1>Done building project "BlazorApp.Shared.csproj".
2>------ Rebuild All started: Project: BlazorApp.Client, Configuration: Debug Any CPU ------
2>C:\some\path\Client\App.razor(1,1,1,45): warning RZ10012: Found markup element with unexpected name 'Router'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\App.razor(2,5,2,32): warning RZ10012: Found markup element with unexpected name 'Found'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\App.razor(3,9,3,81): warning RZ10012: Found markup element with unexpected name 'RouteView'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\App.razor(4,9,4,65): warning RZ10012: Found markup element with unexpected name 'FocusOnNavigate'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\App.razor(6,5,6,15): warning RZ10012: Found markup element with unexpected name 'NotFound'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\App.razor(7,9,7,20): warning RZ10012: Found markup element with unexpected name 'PageTitle'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\App.razor(8,9,8,50): warning RZ10012: Found markup element with unexpected name 'LayoutView'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\Counter.razor(3,1,3,12): warning RZ10012: Found markup element with unexpected name 'PageTitle'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\FetchData.razor(5,1,5,12): warning RZ10012: Found markup element with unexpected name 'PageTitle'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\Index.razor(5,1,5,12): warning RZ10012: Found markup element with unexpected name 'PageTitle'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(15,1,15,91): warning RZ10012: Found markup element with unexpected name 'EditForm'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(16,5,16,31): warning RZ10012: Found markup element with unexpected name 'DataAnnotationsValidator'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(17,5,17,24): warning RZ10012: Found markup element with unexpected name 'ValidationSummary'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(22,13,22,84): warning RZ10012: Found markup element with unexpected name 'InputText'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(23,13,23,58): warning RZ10012: Found markup element with unexpected name 'ValidationMessage'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(30,13,30,104): warning RZ10012: Found markup element with unexpected name 'InputText'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Pages\LogIn.razor(31,13,31,60): warning RZ10012: Found markup element with unexpected name 'ValidationMessage'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Shared\MainLayout.razor(5,9,5,20): warning RZ10012: Found markup element with unexpected name 'NavMenu'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Shared\NavMenu.razor(13,13,13,72): warning RZ10012: Found markup element with unexpected name 'NavLink'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Shared\NavMenu.razor(18,13,18,54): warning RZ10012: Found markup element with unexpected name 'NavLink'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Shared\NavMenu.razor(23,13,23,56): warning RZ10012: Found markup element with unexpected name 'NavLink'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Shared\NavMenu.razor(28,13,28,52): warning RZ10012: Found markup element with unexpected name 'NavLink'. If this is intended to be a component, add a #using directive for its namespace.
2>C:\some\path\Client\Authentication\AuthenticationService.cs(1,7,1,15): error CS0246: The type or namespace name 'Blazored' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Authentication\AuthenticationService.cs(2,28,2,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Authentication\AuthStateProvider.cs(1,7,1,15): error CS0246: The type or namespace name 'Blazored' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Authentication\AuthStateProvider.cs(2,28,2,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Program.cs(1,7,1,15): error CS0246: The type or namespace name 'Blazored' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Program.cs(2,28,2,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Program.cs(3,28,3,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Program.cs(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\App_razor.g.cs(11,32,11,42): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(3,28,3,41): error CS0234: The type or namespace name 'Authorization' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(5,28,5,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(6,28,6,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(7,28,7,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(8,28,8,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(9,28,9,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.cs(11,32,11,42): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(3,28,3,41): error CS0234: The type or namespace name 'Authorization' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(5,28,5,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(6,28,6,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(7,28,7,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(8,28,8,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(9,28,9,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.cs(110,58,110,68): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\App_razor.g.cs(110,53,110,63): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.cs(113,70,113,80): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\App_razor.g.cs(113,70,113,80): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Authentication\AuthStateProvider.cs(9,38,9,65): error CS0246: The type or namespace name 'AuthenticationStateProvider' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Shared_SurveyPrompt_razor.g.cs(11,32,11,42): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(3,28,3,41): error CS0234: The type or namespace name 'Authorization' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(5,28,5,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(6,28,6,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(7,28,7,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(8,28,8,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(9,28,9,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Counter_razor.g.cs(11,32,11,42): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(3,28,3,41): error CS0234: The type or namespace name 'Authorization' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(5,28,5,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(6,28,6,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(7,28,7,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(8,28,8,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(9,28,9,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Authentication\AuthStateProvider.cs(12,26,12,46): error CS0246: The type or namespace name 'ILocalStorageService' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Authentication\AuthenticationService.cs(13,26,13,53): error CS0246: The type or namespace name 'AuthenticationStateProvider' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Authentication\AuthenticationService.cs(14,26,14,46): error CS0246: The type or namespace name 'ILocalStorageService' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Shared_MainLayout_razor.g.cs(11,32,11,42): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(3,28,3,41): error CS0234: The type or namespace name 'Authorization' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(5,28,5,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(6,28,6,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(7,28,7,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(8,28,8,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(9,28,9,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\Authentication\AuthStateProvider.cs(14,26,14,45): error CS0246: The type or namespace name 'AuthenticationState' could not be found (are you missing a using directive or an assembly reference?)
2>C:\some\path\Client\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_FetchData_razor.g.cs(11,32,11,42): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(3,28,3,41): error CS0234: The type or namespace name 'Authorization' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
2>C:\some\path\Client\_Imports.razor(4,28,4,38): error CS0234: The type or namespace name 'Components' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
You can try to check _Import.razor:
#using System.Net.Http
#using System.Net.Http.Json
#using Microsoft.AspNetCore.Components.Forms
#using Microsoft.AspNetCore.Components.Routing
#using Microsoft.AspNetCore.Components.Web
#using Microsoft.AspNetCore.Components.Web.Virtualization
#using Microsoft.AspNetCore.Components.WebAssembly.Http
#using Microsoft.JSInterop
#using BlazorApp1
#using BlazorApp1.Shared
I get this error if delete these in _Import.razor, maybe it can help you.