Blazor WebAssembly debug Program.cs
Asked Answered
J

1

7

I've tried debugging in both vs code and vs.net 2019 and in both cases debugging everything bug Program.cs works. I'm trying to figure out why configuration isn't working but can't step into the code to see what's going on.

Anyone know how to debug this?

Jonna answered 19/6, 2020 at 17:1 Comment(1)
According to the docs: learn.microsoft.com/en-us/aspnet/core/blazor/… you can't hit breakpoints during the startup, so there's that.Following
L
2

I'm pretty sure that you can't debug the Program.cs. I don't remember where I read it (it's here), but I think it said that it had something to do with the debugger attaching to the process after everything in the Program.cs file has been executed. What I do is in any place that I want to check variables or values in that file, I write them to the console. The call to Console.WriteLine() in the Program.cs file just writes directly to the browser's developer console. It isn't the easiest way to debug, but it has worked for me several times. I think the same goes for the first razor component page that is loaded, the debugger will not attach till after it's OnInitialized() or OnInitializedAsync() methods have executed, but any subsequent pages after that should stop on breakpoints. Or even if you navigate away from that first page then navigate back it should then hit your breakpoints.

Lowder answered 19/11, 2021 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.