Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to debug Blazor hosted webassembly 3.2.0 from Visual Studio 2019 16.6.2

I have Visual Studio 2019 16.6.2 installed, along with the .NET Core 3.1.301 SDK and all the necessary Blazor templates.

If I create a brand new Blazor WebAssmbly application, I can run it from Visual Studio by pressing Ctrl+F5 and it opens a new tab on my active browser window and starts fine.

But when I press F5, a new, separate browser window is opened (which is midly annoying), but the page remains at about:blank for a while until an error message appears in Visual Studio:

Failed to launch debug adapter.  Additional information may be available in the output window.

Unable to launch browser: 
"Could not open wss://localhost:5001/_framework/debug/ws-proxy?browser=wsAFFlocalhostA50821FdevtoolsFbrowserFceed3b95-58ac-470a-b10c-5d139cfd7117": timeout after 60000ms

Whether the Blazor WebAssembly application is "Hosted" or not doesn't make a difference.

I've followed the steps in the Enforce HTTPS in ASP.NET Core, but that made no difference.

If, while waiting for the about:blank window to crash, I manually open the client side url on a browser tab, the app loads and the debugger breakpoints are hit. During the short while before it goes on to crash, if I hit Shift+Alt+D I always get the following error:

Unable to find debuggable browser tab
Could not get a list of browser tabs from http://127.0.0.1:9222/json. Ensure your browser is running with debugging enabled.

Resolution

If you are using Microsoft Edge (80+) for your development, follow these instructions:
Press Win+R and enter the following:

msedge --remote-debugging-port=9222 --user-data-dir="C:\Users\sergi\AppData\Local\Temp\blazor-edge-debug" --no-first-run https://localhost:44372/

I get this each and every time, no matter how often I run the command (having closed all browser instances, rebooted, etc).

This happens in both Edge 84 (Edgium) and Chrome.

I should be able to create a new Blazor WebAssembly app and hit F5 on Visual Studio out of the box. What am I missing?

UPDATE

I've just tried using "old Edge" (EdgeHtml) and Firefox as the debug browser in Visual Studio, and both work as expected (meaning that the application at least starts up when pressing F5). The problem apears to be both Chromium-based browsers then...

UPDATE 2

@JamesHancock posted an easy enough workaround in the comments. For a full resolution (and explanation), I've logged a Github issue with the ASP.NET Core team.

like image 956
Sergi Papaseit Avatar asked Jun 12 '20 17:06

Sergi Papaseit


People also ask

How do I install Blazor code in Visual Studio?

Open Syncfusion Blazor Code Extensions in Visual Studio Code Marketplace. Click Install from Visual Studio Code Marketplace. The browser displays a popup window with information such as “Open Visual Studio Code”. When you click Open Visual Studio Code, the Syncfusion Blazor Extension will launch in Visual Studio Code.

What are the supported browsers for Blazor WebAssembly?

That is the case for all modern browsers, including on mobile. Your Blazor WASM application will run fine on Chrome, Edge, Firefox, Safari and also on the mobile variants of these. However, Internet Explorer doesn't support WASM and therefore can't run client-side Blazor apps.


2 Answers

for me I was missing app.UseWebAssemblyDebugging(); in Startup.Configure(). Hope this helps someone.

like image 150
blighty Avatar answered Sep 20 '22 22:09

blighty


It appears that the issue is that if you remove the IIS Express section from the launchSettings.json file of your project, that debugging will then fail to work. And this is true even if you're using VS code against the project directly without IIS proxying or VS.net too.

So the solution is to put back the IIS Express section in the launchsettings.json file and not remove it until this is fixed.

like image 40
James Hancock Avatar answered Sep 18 '22 22:09

James Hancock