CRM demo: Profile page throws null exception

Made my way to the last section of the demo which configures the Profile page.

I can't figure out what is missing that would cause this null exception. I've attached the VS debugger and it fails at the userManager.GetRolesAsync(user) call in the SecurityService.cs file.

The only debug information I could find was:

dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      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 RadzenCrm2.Pages.Profile.<BuildRenderTree>b__0_5(RenderTreeBuilder __builder5)
         at Microsoft.AspNetCore.Components.CascadingValue`1.Render(RenderTreeBuilder builder)

Hi @cottomatte,

Check if the form have ${user != null} expression for Visible property.

Hi @enchev,

That worked thank you!

I'm confused why this worked. I'm hoping you can help me understand.

I understand the syntax. I get that it's not visible unless the ${user} property is set. My confusion comes from the VS debugger showing the user was not null. It only threw the exception when it reached the call to getRolesAsync().

I apologize if I'm missing something obvious.

The exception was raised actually from the .razor code and Visual Studio debugger is confused since it cannot break in razor part of the page.

1 Like