I'm trying to update MudBlazor Nuget Package on Visual Studio 2022 to the latest version 6.12.0.The last package version that my application works fine is 6.1.7.
When I try to update i noticed that the dialogs and menus stop opening.
i watched "getting started" over and over again and everything is "fine" and i have other application that works fine.
Î'm currently using .NET 8 however i have the same problem even with .net7.
here's my program.cs:
using Microsoft.AspNetCore.Authentication.JwtBearer;using Microsoft.IdentityModel.Tokens;using System.Text;using Microsoft.AspNetCore.Components.Authorization;using Blazored.LocalStorage;using AKSoftware.Localization.MultiLanguages;using System.Reflection;using MudBlazor.Services;using MudBlazor;using Microsoft.AspNetCore.Authentication.Cookies;using Microsoft.AspNetCore.Authentication.Google;using Radzen;var builder = WebApplication.CreateBuilder(args);builder.Services.AddHttpContextAccessor();builder.Services.AddScoped<HttpContextAccessor>();// Add services to the container.builder.Services.AddRazorPages();builder.Services.AddServerSideBlazor();builder.Services.AddBlazoredLocalStorage();builder.Services.AddCors();builder.Services.AddHttpClient();builder.Services.AddMudServices(config =>{ config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight; config.SnackbarConfiguration.PreventDuplicates = false; config.SnackbarConfiguration.NewestOnTop = false; config.SnackbarConfiguration.ShowCloseIcon = true; config.SnackbarConfiguration.VisibleStateDuration = 10000; config.SnackbarConfiguration.HideTransitionDuration = 500; config.SnackbarConfiguration.ShowTransitionDuration = 500; config.SnackbarConfiguration.SnackbarVariant = MudBlazor.Variant.Filled;});builder.Services .AddAuthentication( options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; } ) .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = builder.Configuration.GetValue<string>("JwtIssuer"), ValidAudience = builder.Configuration.GetValue<string>("JwtAudience"), IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration.GetValue<string>("JwtSecurityKey"))) }; }) .AddCookie() .AddGoogle(GoogleDefaults.AuthenticationScheme, googleOptions => { googleOptions.ClientId = builder.Configuration["GoogleClientId"]; googleOptions.ClientSecret = builder.Configuration["GoogleClientSecret"]; googleOptions.SaveTokens = true; });builder.Services.AddRadzenComponents();//Some services in herebuilder.Services.AddServerSideBlazor().AddHubOptions(options =>{ // maximum message size of 2MB options.MaximumReceiveMessageSize = 10000000;});//Some services in herebuilder.Services.AddLanguageContainer(Assembly.GetExecutingAssembly());//Servicos para suportar multilanguagebuilder.Services.AddControllers();builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");//Some services in herevar app = builder.Build();// Configure the HTTP request pipeline.if (!app.Environment.IsDevelopment()){ app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts();}app.UseHttpsRedirection();app.UseStaticFiles();app.UseRequestLocalization(GetLocalizationOptions());app.UseRouting();app.UseAuthentication();app.UseAuthorization();app.UseCors( options => options .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader());app.MapBlazorHub();app.MapFallbackToPage("/_Host");app.MapControllers();app.MapRazorPages();app.Run();RequestLocalizationOptions GetLocalizationOptions(){ var cultures = builder.Configuration.GetSection("Cultures") .GetChildren().ToDictionary(x => x.Key, x => x.Value); var supportedCultures = cultures.Keys.ToArray(); var localizationOptions = new RequestLocalizationOptions() .SetDefaultCulture("en-GB") .AddSupportedCultures(supportedCultures) .AddSupportedUICultures(supportedCultures); return localizationOptions;}
And here's my MainLayout.razor:
@using DialogOptions = MudBlazor.DialogOptions@using Variant = MudBlazor.Variant@inherits LayoutComponentBase@inject NavigationManager NavManager@inject IAuthService _authService@inject ILocalStorageService _localStorage@inject IOperationService _operationService@inject IStringLocalizer<App> Localizer@inject IDialogService DialogService<MudThemeProvider Theme="MyCustomTheme" /><MudDialogProvider /><MudSnackbarProvider /><RadzenComponents />@if (load){<MudLayout><MudAppBar Elevation="0"><div class="logo-toggle-section"><MudGrid Style="height: 100%;width: 100%;"><MudItem xs="2"><MudIconButton Icon="@Icons.Material.Filled.Menu" id="collapse-button" Color="Color.Inherit" Edge="Edge.Start" OnClick="@(e => DrawerToggle())" /></MudItem></MudGrid></div><MudSpacer></MudSpacer><NavMenu></NavMenu><MudSpacer></MudSpacer><MudMenu @onclick="OnClickProfile" ActivationEvent="MouseEvent.MouseOver" Class="user-info-section" AnchorOrigin="Origin.BottomLeft" TransformOrigin="Origin.TopCenter" Dense="true"><ActivatorContent><MudStack Row="true"> @if (currentUser?.user_email != null && !uri.Contains("login")) {<MudAvatar Variant="@Variant.Outlined" Style="@($"color:{MudBlazor.Colors.Grey.Lighten5}; border: 1px solid {MudBlazor.Colors.Grey.Lighten5};")">@currentUser.user_email.Substring(0, 1).ToUpper()</MudAvatar><MudStack Justify="@Justify.Center" Spacing="0"><MudText Typo="@Typo.subtitle2">@(currentUser.First_name != currentUser.user_email ? (currentUser.First_name +" " + currentUser.Last_name) : "")</MudText><MudText Typo="@Typo.caption" Style="@(@"font-size: smaller; font-weight: 300;")">@currentUser.user_email</MudText> @* <MudText Align="@Align.End" @onclick="@HandleLogout" style="font-size: smaller; color: lightgray; float: right; cursor: pointer;">@Localizer["Logout"]</MudText> *@</MudStack> }</MudStack></ActivatorContent><ChildContent><MudMenuItem OnClick="OnClickLogout">@Localizer["Logout"]</MudMenuItem></ChildContent></MudMenu> @*<div class="logo-toggle-section"><MudIconButton Icon="@Icons.Material.Filled.MoreVert" Color="Color.Inherit" Edge="Edge.End" /></div>*@<MudDivider></MudDivider><div class="logo-section"><div class="logo"></div></div><div id="rectangle"></div></MudAppBar><MudDrawer @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="2"><SideBar drawerToggle="@_drawerOpen"></SideBar></MudDrawer><MudMainContent Class="main-content"><MudPaper Class="main-paper" Elevation="0"> @Body</MudPaper></MudMainContent></MudLayout>}@code { private string uri; private bool _drawerOpen = true; private int userId; private OrganizationModel currentOrg; private GetUserModel currentUser; private Boolean load; MudTheme MyCustomTheme = new MudTheme { Palette = new Palette { Primary = "#652CB3", AppbarBackground = "#652CB3", AppbarText = "#ffffff", DrawerBackground = "#f7f7f7", Background = "#ffffff" }, LayoutProperties = new LayoutProperties { AppbarHeight = "200px", DrawerWidthLeft = "160px" }, ZIndex = new ZIndex { AppBar = 0 } }; void DrawerToggle() { _drawerOpen = !_drawerOpen; } protected override void OnParametersSet() { uri = NavManager.Uri; } protected async override Task OnInitializedAsync() { //Get info to display to user } private async void HandleLogout() { await _localStorage.ClearAsync(); await _authService.Logout(); currentUser = null; NavManager.NavigateTo(NavManager.BaseUri +"LogOut", true); } private void OnClickLogout() => HandleLogout();}
I tried to remove all other blazor component package but it didn't work.