Description
I just published to Azure a Blazor Wasm SPA I am developing with VS Community 2019. The app starts up successfully in Chrome via the VS debugger, but the published version triggers the exception below (also in Chrome). The exception message, _ gives me no clue as to the problem_. This looks similar to this previous issue dotnet/aspnetcore#16818 that has been fixed. I published 2-3 months ago a much simpler early version of the app, which functionally did what's described below, and it worked at that time.
Curiously, after I first published a few minutes ago, my console log messages indicated the app got through almost all of my main layout's OnInitializedAsync code, including a JSRuntime.InvokeAsync to my JavaScipt initialization code that opens an IndexedDB and returns its Index of keys. But when I tried re-publishing and got the same exception, none of my initialization code ran according to the console log. I can post my OnInitializedAsync code, but since the exception is now happening before any of this code executes, I'm not sure it will be helpful. Any idea what's going on?
Thanks. Steve
Activity
mkArtakMSFT commentedon Sep 16, 2020
Thanks for contacting us.
Can you try out .NET 5.0 RC1 SDK and see whether you will meet the same error or not?
dantronik-bugreporting commentedon Sep 17, 2020
I am getting the same error with .NET 5.0 RC1. Here's the error message:

modulardev2 commentedon Sep 17, 2020
Yep, same issue here. Only in the published version, everything works fine locally. Using RC1, worked fine with Preview 8.
Bob-HL commentedon Sep 17, 2020
Same issue here with RC1
modulardev2 commentedon Sep 18, 2020
After messing with this for awhile today, I was able to fix it on my end using the following workaround, and I hope it can help someone else.
The culprit was the HttpClient.GetStringAsync method. I replaced for example:
await HttpClient.GetStringAsync(page)with
await (await HttpClient.GetAsync(page)).Content.ReadAsStringAsync();Bob-HL commentedon Sep 18, 2020
It works. You saved my day. Thanks.
dantronik-bugreporting commentedon Sep 22, 2020
@mkArtakMSFT Can auto-close on this issue be prevented? It's a valid issue and the original reporter not responding does not mean that no one else of us will.Okay, seems like that already did it.
CincySteve commentedon Sep 22, 2020
Sorry for being so slow to get back in. I installed .Net 5.0 RC1. I verified that I am using VS 16.8, but am not sure if there is some other verification required to confirm other 5.0 RC1 things installed. Anyway, assuming I have done what was necessary, after I re-published, the app still fails to start-up because of the same exception, while still running successfully under the debugger in VS.
I don't have the situation lertoo mentioned.
CincySteve commentedon Sep 22, 2020
Ugh. I just started to run into this exception in the VS debugger, in both v16.7.4 and v16.8.0 Preview 3.0 (.Net 5.0 RC1). That means I am dead in the water until I can either find the cause or a workaround. I could sure use some help.
Added workaround for 5.0-rc1 bug
CincySteve commentedon Sep 23, 2020
I have a couple other small Blazor apps that are not running into this exception. So there is something about my one app that's triggering it.
I have tried, without success:
mkArtakMSFT commentedon Sep 23, 2020
Thanks for sharing details, everyone.
Can somebody please share a minimalistic repro project so we can root cause and address this? Thanks!
41 remaining items
[interp] Throw an InvalidProgramException instead of asserting when t…
eerhardt commentedon Sep 28, 2020
Update - the underlying linker issue has been fixed and is being backported to 5.0. Once that is merged we should be able to close this issue.
Anipik commentedon Sep 28, 2020
@eerhardt is there any work required on the runtime side for this issue for rc2 or GA ?
eerhardt commentedon Sep 28, 2020
I don't believe so. To fix this we will need:
marek-safar commentedon Oct 1, 2020
The changes were backported to 5.0 GA branch and merged to dotnet/sdk
Fix to bypass an issue with publishing blazor applications.
truthz03 commentedon Oct 14, 2020
Hi, I have updated to RC2 today but the error still is present.
The problem seems to be this line from a Nuget Package I'm using:
await Http.GetJsonAsync(ApiUrl + SearchTermParam(SearchTerm));
Is this Bug not fixed unit now?
The strange thing is that if I ran my application with VisualStudio and Debugging everything is working.
If I make a dotnet pusblish with "--configuration Debug" and create a docker container from the output to deploy it on my server this error occures.
lewing commentedon Oct 14, 2020
@truthz03 RC2 was frozen before the fix went in. The fix will be part of 5.0 final.
truthz03 commentedon Oct 14, 2020
Ok. Thanks. Than I will wait for it
Webapp word (#13)
joer33304 commentedon Dec 6, 2020
This issue is NOT fixed. I upgrade to the latest 5 net 5 sdk. Works locally, error appears when deploying to azure on windows hosted app service.
joer33304 commentedon Dec 6, 2020
Just for others coming here, "false " works for me to get rid of the exception
lewing commentedon Dec 7, 2020
@joer33304 can you please open a new issue with the details of the problem you are encountering?