MarimerLLC / csla

A home for your business logic in any .NET application.
https://cslanet.com
MIT License
1.26k stars 402 forks source link

BlazorExample Solution doesn't work with 8.2.4 - Error:Do not call GetAuthenticationStateAsync outside of the DI scope for a Razor component. Typically, this means you can call it only within a Razor component or inside another DI service that is resolved for a Razor component. #4075

Closed jmpotvin closed 3 months ago

jmpotvin commented 3 months ago

I have upgraded the provided BlazorExample to CSLA 8.2.4

Version and Platform CSLA version: 8.2.4 OS: Windows 10 Platform: ASP.NET Core

Code that Fails Just start the solution and click on List People or Add Person.

Stack Trace or Exception Detail The following error is displayed on the screeen: Do not call GetAuthenticationStateAsync outside of the DI scope for a Razor component. Typically, this means you can call it only within a Razor component or inside another DI service that is resolved for a Razor component.

rockfordlhotka commented 3 months ago

I think this is just a configuration issue. I'm pretty sure we fixed the underlying bug behind this exception, and probably didn't update the configuration of the sample app.

The solution should be to use a different application context manager, specifically:

https://github.com/MarimerLLC/csla/blob/v8.x/Source/Csla.AspNetCore/Blazor/ApplicationContextManagerInMemory.cs

Edit:

Hmm, now I'm not sure. the config explicitly uses the new context manager, because it should be using the new CSLA Blazor state management subsystem:

https://github.com/MarimerLLC/csla/blob/cbf53dc94aca206dcd737e48a656feeaeb29d976/Samples/BlazorExample/BlazorExample/BlazorExample/Program.cs#L22

So there may be some other issue occuring here that'll require some research.

rockfordlhotka commented 3 months ago

I tested this against the 8.2.5 codebase and can't replicate, so the fix will be in the next release.

jmpotvin commented 3 months ago

Thanks! I'm upgrading my project from 7 to 8 and encountering the same error message. Do you have a planned release date for 8.2.5?

rockfordlhotka commented 3 months ago

We'll push the release as soon as possible, probably in the next few days.

rockfordlhotka commented 3 months ago

I take it back. Upon further testing today, I am still able to replicate the issue in the v8.x branch.

kcabral817 commented 3 months ago

You have my prayers.

Have a nice day.

Kevin


From: Rockford Lhotka @.> Sent: Friday, July 5, 2024 3:26 PM To: MarimerLLC/csla @.> Cc: Subscribed @.***> Subject: Re: [MarimerLLC/csla] BlazorExample Solution doesn't work with 8.2.4 - Error:Do not call GetAuthenticationStateAsync outside of the DI scope for a Razor component. Typically, this means you can call it only within a Razor component or inside another DI...

I take it back. Upon further testing today, I am still able to replicate the issue in the v8.x branch.

— Reply to this email directly, view it on GitHubhttps://github.com/MarimerLLC/csla/issues/4075#issuecomment-2211431954, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGJTVDRZYRFOWL4GVHDIZUDZK4FQ3AVCNFSM6AAAAABKJYRPR6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRGQZTCOJVGQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

rockfordlhotka commented 3 months ago

@jmpotvin, @kcabral817 - the fix should be in NuGet now.