abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.93k stars 3.44k forks source link

Null Reference Exception >>>> Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.UserMenuComponent #20768

Closed SeanHogg closed 3 weeks ago

SeanHogg commented 2 months ago

Is there an existing issue for this?

Description

When initializing the application a null reference exception is thrown

[09:50:59 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.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.MobileUserMenuComponent.b36_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) [09:50:59 ERR] Unhandled exception in circuit 'xesp37VYPTTflk9xo_FTL4U9Hm6y7UelAW3TV5ztOvs'. System.NullReferenceException: Object reference not set to an instance of an object. at Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.MobileUserMenuComponent.b__36_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) [09:50:59 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.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.UserMenuComponent.b__52_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) [09:50:59 ERR] Unhandled exception in circuit 'xesp37VYPTTflk9xo_FTL4U9Hm6y7UelAW3TV5ztOvs'. System.NullReferenceException: Object reference not set to an instance of an object. at Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.UserMenuComponent.b52_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)

Reproduction Steps

No response

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

8.2.2

User Interface

Blazor Server

Database Provider

EF Core (Default)

Tiered or separate authentication server

Tiered

Operation System

Windows (Default)

Other information

No response

realLiangshiwei commented 2 months ago

Reproduction Steps

SeanHogg commented 2 months ago

.NET Blazor Server app. Steps: Register an account. Then navigate to the root of the application.

sturlath commented 2 months ago

Is this similar to https://github.com/abpframework/abp/issues/20616?

SeanHogg commented 2 months ago

No they are different components.

Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.UserMenuComponent

If someone can point me to the source code I can probably determine the exact line of code.

It happens after authentication and the redirect. I think it's a ICurrentUser check and it's null. 

---- On Thu, 12 Sep 2024 05:15:17 -0400 @.*** wrote ----

Is this similar to #20616?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

rumbledatingllc commented 2 months ago

2024-09-12 10:27:39.022 -04:00 [DBG] Getting all granted permissions from the repository for this provider name,key: U,3a14e5b0-5417-3912-d5e1-d4dde03e6b6b 2024-09-12 10:27:40.307 -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 Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.MobileUserMenuComponent.b36_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) 2024-09-12 10:27:40.314 -04:00 [ERR] Unhandled exception in circuit 'JcVZNcdDbUEqgmRuiMsFbpTWOszrFhoSIR7USN7uJrw'. System.NullReferenceException: Object reference not set to an instance of an object. at Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.MobileUserMenuComponent.b36_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) 2024-09-12 10:27:40.322 -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 Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.UserMenuComponent.b52_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) 2024-09-12 10:27:40.322 -04:00 [ERR] Unhandled exception in circuit 'JcVZNcdDbUEqgmRuiMsFbpTWOszrFhoSIR7USN7uJrw'. System.NullReferenceException: Object reference not set to an instance of an object. at Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.UserMenuComponent.b52_2(RenderTreeBuilder builder2) at Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(Int32 sequence, RenderFragment fragment) at Microsoft.AspNetCore.Components.Authorization.AuthorizeViewCore.BuildRenderTree(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.ComponentBase.<.ctor>b6_0(RenderTreeBuilder builder) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) 2024-09-12 10:27:40.430 -04:00 [DBG] Added 0 entity changes to the current audit log 2024-09-12 10:27:40.430 -04:00 [DBG] Added 0 entity changes to the current audit log 2024-09-12 10:27:40.430 -04:00 [DBG] Added 0 entity changes to the current audit log 2024-09-12 10:27:40.431 -04:00 [DBG] Setting the cache items. Count: 17 2024-09-12 10:27:40.431 -04:00 [DBG] Setting the cache items. Count: 17 2024-09-12 10:27:40.431 -04:00 [DBG] Setting the cache items. Count: 17 2024-09-12 10:27:40.433 -04:00 [DBG] Finished setting the cache items. Count: 17 2024-09-12 10:27:40.433 -04:00 [DBG] Finished setting the cache items. Count: 17 2024-09-12 10:27:40.433 -04:00 [DBG] Finished setting the cache items. Count: 17


rumbledatingllc commented 1 month ago

For those experiencing the error the work around is to create a class that inherits from the MobileUserMenuComponent and to override the SetParametersAsync

using Microsoft.AspNetCore.Components; using Volo.Abp.DependencyInjection; using MobileUserMenuComponent = Volo.Abp.AspNetCore.Components.Server.LeptonXLiteTheme.Themes.LeptonXLite.Toolbar.MobileUserMenuComponent;

namespace YourDotNet8Namespace;

[ExposeServices(typeof(MobileUserMenuComponent))] [Dependency(ReplaceServices = true)] public partial class OverrideMobileUserMenuComponent : MobileUserMenuComponent { public string Name = "My Mobile User Menu Component";

public override async Task SetParametersAsync(ParameterView parameters)
{
    //await base.SetParametersAsync(parameters); //<================ GARBAGE HACK
}

}

realLiangshiwei commented 1 month ago

I can't reproduce the problem with latest version.

abp new BookStore -u blazor-server --tiered -t app --old