ABP Commercial / Blazor Server / EF Core
Hi, we occasionally receive the exception below right after signing in. When we click 'Reload' in the generic blazor error notification at the bottom of the page, the site loads correctly.
Thanks in advance, Brian
2022-05-12 15:35:17.723 -04:00 [WRN] Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
at System.Collections.Generic.AbpDictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Func`2 factory)
at System.Collections.Generic.AbpDictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary`2 dictionary, TKey key, Func`1 factory)
at Volo.Abp.DependencyInjection.AbpLazyServiceProvider.LazyGetService(Type serviceType)
at Volo.Abp.DependencyInjection.AbpLazyServiceProvider.LazyGetService(Type serviceType, Object defaultValue)
at Volo.Abp.DependencyInjection.AbpLazyServiceProvider.LazyGetService[T](T defaultValue)
at Volo.Abp.Domain.Repositories.BasicRepositoryBase`1.get_CancellationTokenProvider()
at Volo.Abp.Domain.Repositories.BasicRepositoryBase`1.GetCancellationToken(CancellationToken preferredValue)
at Volo.Abp.PermissionManagement.EntityFrameworkCore.EfCorePermissionGrantRepository.GetListAsync(String providerName, String providerKey, CancellationToken cancellationToken)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.PermissionManagement.PermissionStore.SetCacheItemsAsync(String providerName, String providerKey, String currentName, PermissionGrantCacheItem currentCacheItem)
at Volo.Abp.PermissionManagement.PermissionStore.GetCacheItemAsync(String name, String providerName, String providerKey)
at Volo.Abp.PermissionManagement.PermissionStore.IsGrantedAsync(String name, String providerName, String providerKey)
at Volo.Abp.Authorization.Permissions.RolePermissionValueProvider.CheckAsync(PermissionValueCheckContext context)
at Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(ClaimsPrincipal claimsPrincipal, String name)
at Volo.Abp.Authorization.PermissionRequirementHandler.HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
at Microsoft.AspNetCore.Authorization.AuthorizationHandler`1.HandleAsync(AuthorizationHandlerContext context)
at Microsoft.AspNetCore.Authorization.DefaultAuthorizationService.AuthorizeAsync(ClaimsPrincipal user, Object resource, IEnumerable`1 requirements)
at Microsoft.AspNetCore.Authorization.DefaultAuthorizationService.AuthorizeAsync(ClaimsPrincipal user, Object resource, String policyName)
at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.AuthorizeAsync(IAuthorizationService authorizationService, Object resource, String policyName)
at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.AuthorizeAsync(IAuthorizationService authorizationService, String policyName)
at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.IsGrantedAsync(IAuthorizationService authorizationService, String policyName)
at Volo.Abp.SettingManagement.Blazor.Settings.EmailingPageContributor.CheckPermissionsInternalAsync(SettingComponentCreationContext context)
at Volo.Abp.SettingManagement.Blazor.Settings.EmailingPageContributor.CheckPermissionsAsync(SettingComponentCreationContext context)
at Volo.Abp.SettingManagement.Blazor.Menus.SettingManagementMenuContributor.CheckAnyOfPagePermissionsGranted(SettingManagementComponentOptions settingManagementComponentOptions, SettingComponentCreationContext settingComponentCreationContext)
at Volo.Abp.SettingManagement.Blazor.Menus.SettingManagementMenuContributor.ConfigureMainMenuAsync(MenuConfigurationContext context)
at Volo.Abp.SettingManagement.Blazor.Menus.SettingManagementMenuContributor.ConfigureMenuAsync(MenuConfigurationContext context)
at Volo.Abp.UI.Navigation.MenuManager.GetInternalAsync(String name)
at Volo.Abp.UI.Navigation.MenuManager.GetAsync(String[] menuNames)
at Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout.Navigation.MainMenuProvider.GetMenuAsync()
at Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout.Navigation.MainSiderbar.smDpWTGvp()
at Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components.ApplicationLayout.Navigation.MainSiderbar.OnInitializedAsync()
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
5 Answer(s)
-
0
Do you use a tiered application template? Is Redis up and running?
-
0
Do you use a tiered application template? Is Redis up and running?
Hi @gterdem, we do not used a tiered application template and we do not utilize Redis. We do, however, utilize the separated tenant schema option in our templated solution.
Thanks
-
0
Can you share your Module configuration?
-
0
Our Blazor Module's configuration (AppBlazorModule.cs) is:
using System; using System.IO; using System.Threading.Tasks; using Blazorise.Bootstrap5; using Blazorise.Icons.FontAwesome; using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using FM.Timepiece.Blazor.Menus; using FM.Timepiece.EntityFrameworkCore; using FM.Timepiece.Localization; using FM.Timepiece.MultiTenancy; using Microsoft.OpenApi.Models; using FM.Timepiece.Blazor.Components.Layout; using Volo.Abp; using Volo.Abp.Account.Pro.Admin.Blazor.Server; using Volo.Abp.Account.Pro.Public.Blazor.Server; using Volo.Abp.Account.Public.Web; using Volo.Abp.Account.Public.Web.ExternalProviders; using Volo.Abp.Account.Web; using Volo.Abp.Account.Public.Web.Impersonation; using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Components.Server.LeptonTheme; using Volo.Abp.AspNetCore.Components.Server.LeptonTheme.Bundling; using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AuditLogging.Blazor.Server; using Volo.Abp.Autofac; using Volo.Abp.AutoMapper; using Volo.Abp.Identity; using Volo.Abp.Identity.Pro.Blazor; using Volo.Abp.Identity.Pro.Blazor.Server; using Volo.Abp.IdentityServer.Blazor.Server; using Volo.Abp.LanguageManagement.Blazor.Server; using Volo.Abp.LeptonTheme.Management.Blazor.Server; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Swashbuckle; using Volo.Abp.TextTemplateManagement.Blazor.Server; using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; using Volo.Saas.Host; using Volo.Saas.Host.Blazor; using Volo.Saas.Host.Blazor.Server; using Volo.Abp.FluentValidation; using MudBlazor.Services; using Syncfusion.Blazor; namespace FM.Timepiece.Blazor; [DependsOn( typeof(TimepieceApplicationModule), typeof(TimepieceEntityFrameworkCoreModule), typeof(TimepieceHttpApiModule), typeof(AbpAspNetCoreMvcUiLeptonThemeModule), typeof(AbpAutofacModule), typeof(AbpSwashbuckleModule), typeof(AbpAccountPublicWebImpersonationModule), typeof(AbpAspNetCoreSerilogModule), typeof(AbpAspNetCoreComponentsServerLeptonThemeModule), typeof(AbpAccountPublicWebIdentityServerModule), typeof(AbpAccountPublicBlazorServerModule), typeof(AbpAccountAdminBlazorServerModule), typeof(AbpAuditLoggingBlazorServerModule), typeof(AbpIdentityProBlazorServerModule), typeof(LeptonThemeManagementBlazorServerModule), typeof(AbpIdentityServerBlazorServerModule), typeof(LanguageManagementBlazorServerModule), typeof(SaasHostBlazorServerModule), typeof(TextTemplateManagementBlazorServerModule) )] [DependsOn(typeof(AbpFluentValidationModule))] public class TimepieceBlazorModule : AbpModule { public override void PreConfigureServices(ServiceConfigurationContext context) { context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => { options.AddAssemblyResource( typeof(TimepieceResource), typeof(TimepieceDomainModule).Assembly, typeof(TimepieceDomainSharedModule).Assembly, typeof(TimepieceApplicationModule).Assembly, typeof(TimepieceApplicationContractsModule).Assembly, typeof(TimepieceBlazorModule).Assembly ); }); } public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); ConfigureUrls(configuration); ConfigureBundles(); ConfigureAuthentication(context, configuration); ConfigureImpersonation(context, configuration); ConfigureAutoMapper(); ConfigureVirtualFileSystem(hostingEnvironment); ConfigureLocalizationServices(); ConfigureSwaggerServices(context.Services); ConfigureExternalProviders(context, configuration); ConfigureAutoApiControllers(); ConfigureBlazorise(context); ConfigureRouter(context); ConfigureMenu(context); ConfigureLeptonTheme(); context.Services.AddSyncfusionBlazor(); context.Services.AddMudServices(); } private void ConfigureUrls(IConfiguration configuration) { Configure<AppUrlOptions>(options => { options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); }); } private void ConfigureBundles() { Configure<AbpBundlingOptions>(options => { // MVC UI options.StyleBundles.Configure( LeptonThemeBundles.Styles.Global, bundle => { bundle.AddFiles("/global-styles.css"); } ); // Blazor UI options.StyleBundles.Configure( BlazorLeptonThemeBundles.Styles.Global, bundle => { bundle.AddFiles("/blazor-global-styles.css"); //You can remove the following line if you don't use Blazor CSS isolation for components bundle.AddFiles("/FM.Timepiece.Blazor.styles.css"); } ); }); } private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddAuthentication() .AddJwtBearer(options => { options.Authority = configuration["AuthServer:Authority"]; options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); options.Audience = "Timepiece"; }); } private void ConfigureImpersonation(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.Configure<SaasHostBlazorOptions>(options => { options.EnableTenantImpersonation = true; }); context.Services.Configure<AbpIdentityProBlazorOptions>(options => { options.EnableUserImpersonation = true; }); context.Services.Configure<AbpAccountOptions>(options => { options.TenantAdminUserName = "admin"; options.ImpersonationTenantPermission = SaasHostPermissions.Tenants.Impersonation; options.ImpersonationUserPermission = IdentityPermissions.Users.Impersonation; }); } private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) { if (hostingEnvironment.IsDevelopment()) { Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.ReplaceEmbeddedByPhysical<TimepieceDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}FM.Timepiece.Domain.Shared")); options.FileSets.ReplaceEmbeddedByPhysical<TimepieceDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}FM.Timepiece.Domain")); options.FileSets.ReplaceEmbeddedByPhysical<TimepieceApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}FM.Timepiece.Application.Contracts")); options.FileSets.ReplaceEmbeddedByPhysical<TimepieceApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}FM.Timepiece.Application")); options.FileSets.ReplaceEmbeddedByPhysical<TimepieceBlazorModule>(hostingEnvironment.ContentRootPath); }); } } private void ConfigureSwaggerServices(IServiceCollection services) { services.AddAbpSwaggerGen( options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "Timepiece API", Version = "v1" }); options.DocInclusionPredicate((docName, description) => true); options.CustomSchemaIds(type => type.FullName); } ); } private void ConfigureExternalProviders(ServiceConfigurationContext context, IConfiguration configuration) { context.Services.AddAuthentication() .AddGoogle(GoogleDefaults.AuthenticationScheme, _ => {}) .WithDynamicOptions<GoogleOptions, GoogleHandler>( GoogleDefaults.AuthenticationScheme, options => { options.WithProperty(x => x.ClientId); options.WithProperty(x => x.ClientSecret, isSecret: true); } ) .AddMicrosoftAccount(MicrosoftAccountDefaults.AuthenticationScheme, options => { //Personal Microsoft accounts as an example. options.AuthorizationEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize"; options.TokenEndpoint = "https://login.microsoftonline.com/consumers/oauth2/v2.0/token"; }) .WithDynamicOptions<MicrosoftAccountOptions, MicrosoftAccountHandler>( MicrosoftAccountDefaults.AuthenticationScheme, options => { options.WithProperty(x => x.ClientId); options.WithProperty(x => x.ClientSecret, isSecret: true); } ) .AddTwitter(TwitterDefaults.AuthenticationScheme, options => options.RetrieveUserDetails = true) .WithDynamicOptions<TwitterOptions, TwitterHandler>( TwitterDefaults.AuthenticationScheme, options => { options.WithProperty(x => x.ConsumerKey); options.WithProperty(x => x.ConsumerSecret, isSecret: true); } ); } private void ConfigureLocalizationServices() { Configure<AbpLocalizationOptions>(options => { options.Languages.Add(new LanguageInfo("ar", "ar", "العربية", "ae")); options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); options.Languages.Add(new LanguageInfo("en", "en", "English")); options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish", "fi")); options.Languages.Add(new LanguageInfo("fr", "fr", "Français", "fr")); options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in")); options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); options.Languages.Add(new LanguageInfo("ru", "ru", "Русский", "ru")); options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak", "sk")); options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe")); options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文")); options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de")); options.Languages.Add(new LanguageInfo("es", "es", "Español")); }); } private void ConfigureBlazorise(ServiceConfigurationContext context) { context.Services .AddBootstrap5Providers() .AddFontAwesomeIcons(); } private void ConfigureMenu(ServiceConfigurationContext context) { Configure<AbpNavigationOptions>(options => { options.MenuContributors.Add(new TimepieceMenuContributor()); }); } private void ConfigureLeptonTheme() { Configure<Volo.Abp.AspNetCore.Components.Web.LeptonTheme.LeptonThemeOptions>(options => { options.FooterComponent = typeof(MainFooterComponent); }); } private void ConfigureRouter(ServiceConfigurationContext context) { Configure<AbpRouterOptions>(options => { options.AppAssembly = typeof(TimepieceBlazorModule).Assembly; }); } private void ConfigureAutoApiControllers() { Configure<AbpAspNetCoreMvcOptions>(options => { options.ConventionalControllers.Create(typeof(TimepieceApplicationModule).Assembly); }); } private void ConfigureAutoMapper() { Configure<AbpAutoMapperOptions>(options => { options.AddMaps<TimepieceBlazorModule>(); }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var env = context.GetEnvironment(); var app = context.GetApplicationBuilder(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAbpRequestLocalization(); if (!env.IsDevelopment()) { app.UseErrorPage(); app.UseHsts(); } app.UseHttpsRedirection(); app.UseCorrelationId(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); } app.UseUnitOfWork(); app.UseIdentityServer(); app.UseAuthorization(); app.UseSwagger(); app.UseAbpSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Timepiece API"); }); app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); } }
-
0
hi,
this is not a everytime reproducable issue therefore we'll check this situation and let you know