Thank you! It work well now.
Let'm give you more detail description.
Yes, I am using Blazor Server. With the same code, If I use Lepton, there is no error. After I replace/change the theme from Lepton to LeptonX, I will get above error.
[11:57:25 DBG] PermissionStore.GetCacheItemAsync: pn:U,pk:2b080ea8-6fdc-5e40-685e-39fe0f560247,n:ChangeAdmin.Admin
[11:57:25 DBG] Not found in the cache: pn:U,pk:2b080ea8-6fdc-5e40-685e-39fe0f560247,n:ChangeAdmin.Admin
[11:57:25 DBG] Getting all granted permissions from the repository for this provider name,key: U,2b080ea8-6fdc-5e40-685e-39fe0f560247
[11:57:26 DBG] PermissionStore.GetCacheItemAsync: pn:U,pk:2b080ea8-6fdc-5e40-685e-39fe0f560247,n:SettingManagement.Emailing
[11:57:26 DBG] Not found in the cache: pn:U,pk:2b080ea8-6fdc-5e40-685e-39fe0f560247,n:SettingManagement.Emailing
[11:57:26 DBG] Getting all granted permissions from the repository for this provider name,key: U,2b080ea8-6fdc-5e40-685e-39fe0f560247
[11:57:26 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 Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.SideMenu.Navigation.MobileNavbar.BuildRenderTree(RenderTreeBuilder __builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
[11:57:26 DBG] PermissionStore.GetCacheItemAsync: pn:U,pk:2b080ea8-6fdc-5e40-685e-39fe0f560247,n:ChangeAdmin.Admin
[11:57:26 DBG] Not found in the cache: pn:U,pk:2b080ea8-6fdc-5e40-685e-39fe0f560247,n:ChangeAdmin.Admin
[11:57:26 DBG] Getting all granted permissions from the repository for this provider name,key: U,2b080ea8-6fdc-5e40-685e-39fe0f560247
[11:57:26 DBG] Added 0 entity changes to the current audit log
[11:57:26 DBG] Added 0 entity changes to the current audit log
[11:57:26 DBG] Added 0 entity changes to the current audit log
[11:57:26 DBG] Added 0 entity changes to the current audit log
Good question, I will prepare a new ABP solution for you. After I create it by ABP Suite.
At first, I placed the code in PreConfigureServices. Failed as before. Then, I placed the code in ConfigureServices, Failed again.
I place the code in ConfigureServices and PreConfigureServices.
Configure<AbpLocalizationOptions>(options =>
{
options.DefaultResourceType = typeof(BlazorOneResource);
});
But I still get the same error as before.
I have checked the source code of ABP Framework. Volo.Abp.FeatureManagement Volo.Abp.FeatureManagement.Blazor /Components/FeatureManagementModal.razor line 65.
I past the code as below
<SelectItem Value="@item.Value">
@CreateStringLocalizer(item.DisplayText.ResourceName).GetString(item.DisplayText.Name)
</SelectItem>
Sometimes, CreateStringLocalizer(item.DisplayText.ResourceName) return a null object. So, GetString will throw exception.
You may think these senarios: Such as I change the file name /class name of Resource file. But a feature setting has already been stored into database many months ago...
[11:33:59 WRN] Unhandled exception rendering component: Value cannot be null. (Parameter 'stringLocalizer')
System.ArgumentNullException: Value cannot be null. (Parameter 'stringLocalizer')
at Microsoft.Extensions.Localization.StringLocalizerExtensions.GetString(IStringLocalizer stringLocalizer, String name)
at Volo.Abp.FeatureManagement.Blazor.Components.FeatureManagementModal.<>c__DisplayClass43_5.<BuildRenderTree>b__21(RenderTreeBuilder __builder9)
at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment)
at Blazorise.SelectItem`1.BuildRenderTree(RenderTreeBuilder __builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
[11:33:59 ERR] Unhandled exception in circuit 'qZ_yD2E2sEZ7bY4bLqK6QptNM2WMr0hCZRrjd-heQQk'.