Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Using Session: System.InvalidOperationException: Property Session is not Initialized #675

Open
neozhu opened this issue May 3, 2024 · 4 comments

Comments

@neozhu
Copy link

neozhu commented May 3, 2024

I’m currently integrating the Session feature in my project using Fusion, but I'm encountering an error that I need help with. The error message I receive is: System.InvalidOperationException: Property Session is not initialized.

Here’s the configuration I’m using (please include your configuration details here; you can omit any sensitive information).

 services.AddFusion(fusion => {
     fusion.AddInMemoryAuthService();
     fusion.AddInMemoryKeyValueStore();
     fusion.AddAuthClient();
     fusion.AddBlazor().AddAuthentication().AddPresenceReporter();
     fusion.AddService<IUserSessionTracker,UserSessionTracker>();
     fusion.AddService<IOnlineUserTracker, OnlineUserTracker>();
 });


@inherits ComputedStateComponent<UserInfo[]>
@inject IOnlineUserTracker OnlineUserTracker
@inject IStringLocalizer<ActiveUserSession> L
@inject Session Session
@implements IAsyncDisposable
[10:20:32 ERR ::1] Unhandled exception in circuit '6HBk0xzeF0auuhxEMHo44PsVFqsIbK-Ji4ezMFm1Vac'.
System.InvalidOperationException: Property Session is not initialized.
   at ActualLab.Fusion.SessionResolver.get_Session()
   at ActualLab.Fusion.FusionBuilder.<>c.<.ctor>b__12_21(IServiceProvider c)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.<CreatePropertyInjector>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)

Could you guide me on the proper setup to use Session correctly within the project? Any help would be much appreciated!

Thank you!

@adambajguz
Copy link

Hi @neozhu, open issue here https://github.com/ActualLab/
It looks like this repo migrated without any notice.

@alexyakunin
Copy link
Collaborator

@adambajguz thanks - @neozhu yeah, please report the issue in https://github.com/ActualLab/Fusion repo.

As for the exception, it happens because SessionResolver (a scoped service) doesn't have its Session property set, which is supposed to be initialized as early as possible after Blazor circuit creation; typically this happens in OnInitialized method of your root component.

@adambajguz
Copy link

@alexyakunin why don't archive this repo?

@alexyakunin
Copy link
Collaborator

@alexyakunin why don't archive this repo?

Because I don't own this repo - i.e. it's up to ServiceTitan. And agreeing on how to handle this may take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants