Templates icon indicating copy to clipboard operation
Templates copied to clipboard

error when use .net 8 template with interactive render auto

Open marceloperegil opened this issue 1 year ago • 9 comments

Steps to reproduce error:

  1. install template with the command: dotnet new mudblazor --interactivity Auto
  2. run the proyect
  3. go to counter page
  4. click on counter button
  5. refresh the page
  6. get the error image

marceloperegil avatar Jan 19 '24 16:01 marceloperegil

@mikes-gh isn't the problem related because the template is using rc libs. I'm slightly surprised it went like this in prod

ScarletKuro avatar Jan 19 '24 23:01 ScarletKuro

I did ask for them to be updated :-( ~~But thats not the problem in this case cause I updated them to 8.0.1 and the problem remains~~ edit it is the problem

mikes-gh avatar Jan 19 '24 23:01 mikes-gh

@ScarletKuro You are right. After a clean and rebuild with 8.0.1 the issue is resolved

mikes-gh avatar Jan 19 '24 23:01 mikes-gh

I had to also clean obj and bin folders

JarFrank avatar Jan 24 '24 14:01 JarFrank

https://github.com/MudBlazor/Templates/issues/453#issuecomment-1901309111 This worked for me.

marceloperegil avatar Jan 24 '24 17:01 marceloperegil

I am seeing the same error as initially described. Cleaning and rebuilding does not fix it for me. Also, I see it in every single, freshly created MudBlazor project. Here's what I did:

  • In Visual Studio, I create a new project using the template "MudBlazor Web App (MudBlazor)", with .NET 8.0, no authentication and interactive render mode "Auto (Server and WebAssembly)", globally set: grafik

Once it's created, I change nothing at all and start debugging (F5):

  • After the first loading, it works: hiding/showing the sidebar, switching over to the counter page, increasing count by clicking the button.
  • As soon as I reload or start the second debugging session (or each time after that), there's no interactivity any more (clicking the three-bars-symbol to hide the sidebar does nothing, neither does clicking the counter button), and a JSON error appears in the console:

grafik (Also, the CSS file gets a 404 now).

  • Clicking the sidebar link "Counter" shows a lot of errors in the console:
    grafik

  • This happens across all the browsers I've tried: Firefox, Brave, Edge. I've tried this in Visual Studio 2022 (17.8.6) as well as VS Code 1.86.0 - it's exactly same everywhere: First run after creating the project is okay, second and every after that fails.

  • My installed .NET SDK is 8.0.101.

  • MudBlazor templates installed are the latest (0.6.5).

  • I'm using Windows 11 Pro (23H2).

To rule out a configuration problem, I have uninstalled .NET entirely and made a clean install. I did the same with Visual Studio (removed completely and did a clean install). It changed nothing. I've used MudBlazor with .NET 6 and never experienced any problems like this.

Also, when using the "original" Blazor Web App template that comes with Visual Studio, applying the same settings as above, it works without a problem, no matter how often I reload / restart. The same goes for the Fluent UI template: It works both server side as well as after the switch to client side - so clearly, there's an issue with MudBlazor somehow...

My impression is that something goes/is wrong with the way WebAssembly render mode is configured/hooked in (since the problem occurs after the first reload, i.e. after the switch from server side to client side. Sadly, I cound't figure out what "the other" templates (the "original" one or Fluent UI) do differently regarding this...

I do think that MudBlazor is fantastic, and I'd really, really love to use this rather than Bootstrap (oiriginal template) or Fluent UI. So - how could this problem best be tackled?

Thanks to everybody investing tehir time to work on MudBlazor and to help other people!

philipp-koch avatar Feb 10 '24 23:02 philipp-koch

@philipp-koch have you updated the underlying libraries (Microsoft.AspNetCore.Components.WebAssembly.Server, Microsoft.AspNetCore.Components.WebAssembly and all other MS libraries) to 8.0.1 as the issue suggests? Then clear obj / bin / .vs(hidden) folders, clean browser cache etc.

ScarletKuro avatar Feb 11 '24 00:02 ScarletKuro

@ScarletKuro Thank you for pointing this out so clearly - I was mistaken, thinking "8.0.1" referred to the installed .NET SDK! So, I've taken a look at the NuGet package manager, and indeed the mentioned packages were still the RC versions, not 8.0.1. I have updated them, performed clean and rebuild for the solution, cleared the browser cache - and voilà, it works now! So, in other words: "Amazing, just do it right and all of a sudden it works!" (Kaum macht man's richtig, schon funktioniert's...) 🤣

I'm a little embarassed now, but more importantly, I'm really happy this could be solved (so easily)...

Thanks for your quick and helpful reply!

philipp-koch avatar Feb 11 '24 15:02 philipp-koch

Hopefully https://github.com/MudBlazor/Templates/pull/454 will be merged soon, so it will work out of the box.

ScarletKuro avatar Feb 11 '24 15:02 ScarletKuro