I'm trying to use Blazor WebAssembly. I create a project and the code isL
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app"); // Error there : The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
await builder.Build().RunAsync();
}
}
As I comment in the code, App is not found by intellisense and an error is shown. I can't use f12 on the word "App" (unfound). I can build and launch the project but I want to clean it properly.
I followed this thread : Blazor the type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) but it didn't fix it.
My IDE is Visual Studio Community : Microsoft Visual Studio Community 2019 Version 16.6.2 and dotnet --version gives : 5.0.100-preview.6.20318.15
Thank you very much.
make sure that all the packages using by your project has been updated and compatible with .net 5.
Updating these two packages resolved the issue for me:
Microsoft.AspNetCore.Components.WebAssembly Microsoft.AspNetCore.Components.WebAssembly.DevServer