aspnetcore: Blazor error after update to .NET 8: Failed to start platform.
I’ve tried to update my solution to .NET 8 RC.1. I’ve updated all packages and cleaned all bin and obj folders. Still, I ended up with the following error:
Failed to start platform. Reason: TypeError: Cannot read properties of undefined (reading ‘AspNetCore’)
This error shows up in the browser console when I start the app and open the Blazor client website. Is this a known issue? How can I go about debugging it?
My solution contains 3 distinct Blazor clients. One client works fine after update, two get this error, so I think this will be a common issue. I don’t have an example project I could share publicly, but I thought it’s worth creating the issue, so when others fail to update to .NET 8 and face the same issue, they can find it, give it a 👍 or contribute.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 19
- Comments: 27
@pekspro @sequarell
I was able to resolve this by:
I noticed that the versions in VS didn’t match the packagereference versions. NOthing except actually copy-pasting them in and out actually resolved this.
Seems to be some kind of bug in VS preview.
Excacly the same issue with the released version from today. Cache storage cleaning doesnt help. The only thing that really helps me was the tip from @AbstractionsAs
Cutting the packagereferences from the .csproj Saving the csproj and waiting for the references to update in VS Pasting the packagereferences back in Clean Rebuild
that works for me
What worked for me was manually deleting the folders under bin\Debug and rebuilding, not deleting the cache. Also it seems that 8.0 now requires a connection to the internet in order to debug aד it downloads files from https://raw.githubusercontent.com/dotnet/runtime We had to exclude this path on the proxy to be able to develop.
I’m having a similar issue. Clearing the cache storage seems to fix it:
Same here.
Upgrading from WASM app from 7 to 8.
App refused to load (“Failed to start platform …” error on console) Only after performing “clean” the app worked.
I assume this has to be due to old assets not being cleaned up in the bin/obj folders. Just delete the bin/obj folders, restore the nuget packages, build and run the blazor application.
@AbstractionsAs, @sequarell, this thread is closed, I doubt anyone is watching 😃
I’ve created a new thread here: https://github.com/dotnet/aspnetcore/issues/51268
To resolve this issue go to program.cs of your client project(if you are using ASP.NETCORE Hosted blazor WASM) and replace this
builder.Services.AddHttpClient("yourApplicationName.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))to
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });this will resolve the error “Failed to start platform. Reason: TypeError: Cannot read properties of undefined (reading ‘AspNetCore’)”
The same thing happens to me with Rider. Just had to delete bin/obj folders and then do a nuget restore making sure all packages were the latest (8.0.6).
I am having this error on Edge browser (chrome works fine) , it’s built by GitHub actions and deployed to Cloudflare pages. @AbstractionsAs’s solution seems like a local environment solution.
update: as mentioned in another ticket, the issue is cache-related. In my case, cloudflare cdn was caching some files. I triggered purge cache and the issue is gone.
FWIW, the specific error from the OP (
reading 'AspNetCore') can happen if you remove the package references toMicrosoft.AspNetCore.Components.WebAssemblyfrom the Blazor wasm project.Maybe it doesn’t help your case but .net 8 rc1 is broken. Try with preview7 or daily rc2 builds.