r/Blazor • u/SimpleTruth2753 • Oct 10 '20
Debugging a Blazor application
Why is Blazor so fragile and near impossible to debug?
I'm creating an application, but any minor change causes the Client-side to fail and no longer load, and becomes impossible to debug.
It turns a 1 hour development effort into a week-long affair.
About ready to kick this BS project to the curb and work in React.
5
u/Frozen_Turtle Oct 10 '20
I've had a great experience with serverside - are you using clientside?
2
u/SimpleTruth2753 Oct 10 '20
Yes, server-side works fine for me. It's Client-side that's giving me issues.
2
u/lablegmerr Oct 10 '20
Host a WASM server side for debugging purpose
https://stackoverflow.com/questions/63766985/run-blazor-wasm-as-blazor-server-side/63766986#63766986
1
u/SimpleTruth2753 Oct 10 '20
Hadn't seen this. Thank you for this. I'll definitely make use of this.
1
u/SimpleTruth2753 Oct 10 '20
Current error showing in the console, which is proving difficult to track down:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Sequence contains no elements
System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source) <0x2f877b0 + 0x0001e> in <filename unknown>:0
atBlazorClient.Client.ApiAuthenticationStateProvider.GetClaimsDetails (System.String type) [0x000e2] in E:\Repo\BlazorClient\Client\ApiAuthenticationStateProvider.cs:60
at BlazorClient.Client.Shared.LoginDisplay.OnInitializedAsync () [0x0002a] in E:\Repo\BlazorClient\Client\Shared\LoginDisplay.razor:34
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x2bf8f20 + 0x0013a> in <filename unknown>:0
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask (System.Threading.Tasks.Task taskToHandle) <0x2dbf148 + 0x000b6> in <filename unknown>:0
1
u/cjb110 Oct 11 '20
Sounds like your rendering a list/collection, that's either empty or not initialized.
1
u/sr955 Oct 15 '20
This is most like due to this: If you are rendering a list make sure you say List<string> list = new List<string>() when you declare it.
1
u/TheTitanGesticulated Oct 25 '20
I’ve had the same experience when running WASM directly using MS’s “dev server” which is still absolute shit as of .NET 5 RC2. Debug as a hosted app, should solve that problem, but you’ll find new ones too. Unfortunately as stable as Blazor is right now, the tooling is complete garbage still. Also quick tip, because of the garbage tooling, every time you rename a razor file, or move to a separate folder. Delete your entire bin and obj folder. Tooling doesn’t have file system watcher in place and doesn’t recognize the changes without a delete or restart of VS.
1
9
u/affenkonig11b Oct 10 '20
My experience is the exact opposite. You can set proper break points, inspect objects, step into/over/through and generally do everything else you can in a fully fledged IDE with any other c# project. Perhaps if you elaborate on your issue, someone could provide useful input.