-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is ThemeManager Broken in version 7? MissingMethodException: Method not found: 'MudBlazor.Palette MudBlazor.MudTheme.get_Palette()'. #25
Comments
Hi. Yes, it's obviously not supported for now as many things changed, ThemeManager is referencing v6, not v7. The update will happen probably after v7 release. |
Yep forked it and kind of got it working. Just an issue to resolve regarding MudColor and conversion to hexStr... The RGBA colors etc... is some refactoring since the Palette class was made abstract. Nice work. |
Maybe you want to PR your changes? Since we need that anyway. |
@ScarletKuro Did you find the time to work on this, yet? Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Method not found: MudBlazor.Palette MudBlazor.MudTheme.get_Palette()
System.MissingMethodException: Method not found: MudBlazor.Palette MudBlazor.MudTheme.get_Palette()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.ErrorBoundaryBase.Microsoft.AspNetCore.Components.IErrorBoundary.HandleException(Exception exception)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.HandleExceptionViaErrorBoundary(Exception error, ComponentState errorSourceOrNull) … and that's while I'm on latest .NET 8.0.8 & MudBlazor 7.7.0! 😞 |
@Eagle3386 Did you update ThemeManager to |
Of course! 😎 |
Can you upload the project? I tested, and the test app from this repo is working just fine with the 7.7.0 mud. If there was method missing, it wouldn't compile. |
I can't due to IP of the source code. <MudThemeManagerButton OnClick="_ => OpenThemeManager(true)" />
<MudThemeManager Open="IsThemeManagerOpen" OpenChanged="OpenThemeManager" Theme="ThemeManager" ThemeChanged="UpdateTheme" /> At the top, there's of course <MudThemeProvider @ref="ThemeProvider" Theme="ThemeManager.Theme" @bind-IsDarkMode="IsThemeDarkMode" /> and the code for the mentioned methods looks like this: protected override async Task OnAfterRenderAsync(bool isFirstRender)
{
if (isFirstRender)
{
await Task.WhenAll(OnIsDarkModeChangedAsync(null), ThemeProvider.WatchSystemPreference(OnPreferenceChangedAsync));
}
await base.OnAfterRenderAsync(isFirstRender);
}
/// … left out for brevity
private static MudTheme Theme { get; } = new()
{
LayoutProperties = new() { DefaultBorderRadius = "6px" },
PaletteLight = new()
{
AppbarBackground = new("…"),
Primary = new("…"),
Secondary = new("…"),
SecondaryContrastText = new("…"),
Tertiary = new("…"),
TextSecondary = new("…")
},
ZIndex = new() { Popover = new ZIndex().AppBar + 1 } // Workaround until MudBlazor/#6909 is fixed
};
private static ThemeManagerTheme ThemeManager { get; set; } = new()
{
AppBarElevation = 5,
DefaultBorderRadius = int.Parse(Theme.LayoutProperties.DefaultBorderRadius[..^2]),
DrawerClipMode = DrawerClipMode.Always,
DrawerElevation = 5,
Theme = Theme
};
private static MudThemeProvider ThemeProvider { get; set; }
private async Task OnIsDarkModeChangedAsync(bool? newValue) =>
await OnPreferenceChangedAsync((IsDarkMode = newValue) ?? await ThemeProvider!.GetSystemPreference());
private Task OnPreferenceChangedAsync(bool newValue)
{
IsThemeDarkMode = newValue;
return InvokeAsync(StateHasChanged);
}
private static Task<bool> OpenThemeManager(bool isOpen) => Task.FromResult(IsThemeManagerOpen = isOpen);
private Task UpdateTheme(ThemeManagerTheme theme)
{
ThemeManager = theme;
return InvokeAsync(StateHasChanged);
} |
Make a small reproduction from what you got, otherwise can't help you or fix it if there is a problem indeed. |
I actually supposed - given my snippets above - you're able to create it yourself, but meanwhile found out that the problem must lay somewhere else as it even works with my original Besides, after having a hard time & multiple headaches, I finally found the culprit: for some reason, VS didn't really rebuild the solution after upgrading both MudBlazor packages. |
Have to add: while in
|
This is totally two different unrelated exceptions. |
But I neither publish with enabled AOT nor did I enable trimming within my Blazor WASM project file nor the <!--<PublishTrimmed>true</PublishTrimmed>
<PublishAot>false</PublishAot> 🤷🏻♂️🤔 |
Trimming is the default behavior starting from net8. |
I guess this stacktrace will be "won't fix" for now. We need to use source generation to resolve the trimming issue in the This is also a good opportunity to remind everyone that the README for ThemeManager explicitly states that this component is not suitable for production applications. Therefore, you shouldn't publish an app using it. It’s intended for use in debug mode to experiment with settings and find what works best for your theme. |
Thanks for your explanation & insights, Artyom. Much appreciated! 👏🏻👍🏻 However, I'm not shipping the app with the ThemeManager, except for the staging/testing environment where the UI / UX folks are meant to do their experiments - and besides "pure" developers, debug builds shouldn't be used by anyone else. |
Try 2.1.0 https://www.nuget.org/packages/MudBlazor.ThemeManager/2.1.0 |
Sorry for the delay, but can finally confirm the "ugly way" is working. 😅👍🏻 |
I'm using
When running my application I recieve the following exception.
MissingMethodException: Method not found: 'MudBlazor.Palette MudBlazor.MudTheme.get_Palette()'.
Question
Is this a problem with version 7 where they changed "Palette" to "LightPallet" to match the "DarkPallet" naming scheme?
Thanks In Advance
The text was updated successfully, but these errors were encountered: