You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ScopedLifestyle implementations contains an GetCurrentScope method that allows retrieving the scope for the current context. In some special circumstances, however, it could be beneficial to allow an existing scope to be provided and set as scope for the current context.
Microsoft's new Blazor uses a single IServiceScope for the duration of a single session. During callbacks (for instance when handling click events), however, the asynchronous context, which is used by the AsyncScopedLifestyle, gets reset, causing Simple Injector Scope to be gone. When a user calls Container.GetInstance, they might be prompted with an "the instance is requested outside the context of an active (Async) scope" exception.
To combat this, the user's infrastructure code that integrates Simple Injector with Blazor (or Simple Injector's own future integration package) could ensure the current Simple Injector Scope is set to the current asynchronous context using a ScopedLifestyle.SetCurrentScope method.
The text was updated successfully, but these errors were encountered:
ScopedLifestyle
implementations contains anGetCurrentScope
method that allows retrieving the scope for the current context. In some special circumstances, however, it could be beneficial to allow an existing scope to be provided and set as scope for the current context.Microsoft's new Blazor uses a single
IServiceScope
for the duration of a single session. During callbacks (for instance when handling click events), however, the asynchronous context, which is used by theAsyncScopedLifestyle
, gets reset, causing Simple InjectorScope
to be gone. When a user callsContainer.GetInstance
, they might be prompted with an "the instance is requested outside the context of an active (Async) scope" exception.To combat this, the user's infrastructure code that integrates Simple Injector with Blazor (or Simple Injector's own future integration package) could ensure the current Simple Injector
Scope
is set to the current asynchronous context using aScopedLifestyle.SetCurrentScope
method.The text was updated successfully, but these errors were encountered: