简体   繁体   English

无法调试客户端 blazor

[英]Cannot debug client side blazor

Ok so plain and simple, I cannot seem to debug client-side blazor.好吧,如此简单明了,我似乎无法调试客户端 blazor。

I have added我已经添加了

"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"

As suggested here Blazor WebAssembly 3.2.0 Preview 3 release now available正如此处所建议的那样, Blazor WebAssembly 3.2.0 Preview 3 版本现已发布

I have tried F5 with both IIS Express and kestrel.我已经用 IIS Express 和 kestrel 尝试过 F5。

I have read that you need to enable Script Debugging.我已阅读您需要启用脚本调试。 I switched that on and now when I F5 my browser tries going to我打开了它,现在当我按 F5 时,我的浏览器尝试访问

file:///C:/%5CProgramData%5CMicrosoft%5CVisualStudio%5CEdgeAdapter%5C8d1196ff/landingPage.html

I can confirm I have the following in server -> startup.cs under env.IsDevelopment我可以确认我在 env.IsDevelopment 下的 server -> startup.cs 中有以下内容

app.UseWebAssemblyDebugging();

Tried Alt+Shift+D then Win+R and finally in the new browser window, Alt+Shift+D again.尝试了 Alt+Shift+D,然后是 Win+R,最后在新的浏览器窗口中,再次 Alt+Shift+D。 This seems only to benefit the server-side, which was working anyway.这似乎只有益于服务器端,无论如何它都在工作。

Tried the various suggestions from here Unable to debug Blazor hosted WebAssembly 3.2.0 from Visual Studio 2019 16.6.2尝试了此处的各种建议Unable to debug Blazor hosting WebAssembly 3.2.0 from Visual Studio 2019 16.6.2

Visaul Studio Version: 16.7.2 Visaul Studio 版本:16.7.2
.NetCore 3.1.401 .NetCore 3.1.401
Edge (Chromium) Version 84.0.522.63 Edge(铬)版本 84.0.522.63

I know a few places I have seen people saying their breakpoints get ignored.我知道有几个地方我看到人们说他们的断点被忽略了。 Not sure if they mean the same as this but for me, Visual Studio says the breakpoints will never get hit and no symbols have been loaded, when debugging.不确定它们是否与此相同,但对我来说,Visual Studio 说在调试时断点永远不会被命中,也没有加载任何符号。

UPDATE 1:更新 1:
Just for curiosity, I created a brand new project.出于好奇,我创建了一个全新的项目。
Visual Studio -> Blazor App -> Blazor WebAssembly App Visual Studio -> Blazor 应用程序 -> Blazor WebAssembly 应用程序
Configure for HTTPS is unticked ASP.NET Core hosted is ticked为 HTTPS 配置未勾选 托管的 ASP.NET Core 已勾选

Put a breakpoint at IncrementCount() on Counter.Razor in the client project.在客户端项目的Counter.Razor上的IncrementCount()处放置一个断点。
F5 and the same issue. F5 和同样的问题。

UPDATE2:更新2:
So just to add some more info to the mix.所以只是为了添加更多信息。 I installed Visual Studio Code.我安装了 Visual Studio 代码。 Then I created a hosted project in command line.然后我在命令行中创建了一个托管项目。 Opened the project, put a breakpoint in the same place as UPDATE1 mentioned above, and hit F5.打开项目,在上面提到的 UPDATE1 相同的地方下一个断点,然后按 F5。 The breakpoint works!断点有效!

So, I then opened the project mentioned in UPDATE 1, in Visaul Studio Code and tried that.因此,我随后在 Visaul Studio Code 中打开了更新 1 中提到的项目并进行了尝试。 When I hit F5 I get a blank browser and after a few moments, I get this.当我按 F5 时,我得到一个空白浏览器,过了一会儿,我得到了这个。

在此处输入图像描述

If, in visual studio, I then open the project that I created with command line.如果,在 Visual Studio 中,然后我打开我用命令行创建的项目。 Pressing F5 still doesn't allow breakpoints.按 F5 仍然不允许断点。

So it does seem like a Visaul Studio issue.所以它看起来确实是 Visaul Studio 的问题。

A problem like this is also described on the documentation page for blazor debugging . blazor 调试文档页面上也描述了这样的问题。

Although the example used is for the OnInitialized method, I found that it also works for other methods when the debugger doesn't seem to be triggered.尽管使用的示例是针对 OnInitialized 方法的,但我发现当调试器似乎没有被触发时,它也适用于其他方法。

Just add Thread.Sleep(10000) or await Task.Delay(10000) at the start of your method and try again.只需在方法开始时添加Thread.Sleep(10000)await Task.Delay(10000)试。

Looks like a repair install of visual studio solved the problem.看起来像visual studio的修复安装解决了这个问题。 I noticed that Visaul Studio code had no issues and, when debugging, it always launched a new browser window.我注意到 Visaul Studio 代码没有问题,并且在调试时,它总是启动一个新的浏览器窗口。
Visaul Studio was always launching a new tab on my existing browser windows. Visaul Studio 总是在我现有的浏览器窗口上启动一个新选项卡。

After repair, visual studio started launching a new browser window.修复后,visual studio 开始启动一个新的浏览器窗口。 Not sure if that means anything to anyone.不确定这对任何人是否意味着什么。

It could happen when app.UseWebAssemblyDebugging()<\/code> stands after app.UseHttpsRedirection()<\/code> in a server app Startup.cs.app.UseWebAssemblyDebugging()<\/code> app.UseHttpsRedirection()<\/code>在服务器应用 Startup.cs 中位于app.UseWebAssemblyDebugging()<\/code>之后时,可能会发生这种情况。 So debug file are not available without https.所以调试文件没有 https 是不可用的。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM