Skip to content

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

@neozhu

Description

@neozhu

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions