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

Use Root scope when current is null (fixes #646) #670

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ltines
Copy link
Contributor

@ltines ltines commented May 19, 2024

Fixes #646 by using Root scope when current scope in ExtensionContainerScopeCache.current is null. This can happen when WindsorScopedServiceProvider is called from a new thread (or rather different async context).

In this situation ForcedScope uses the original root scope. It also restores it as ExtensionContainerScopeCache.current on dispose.

The only case that I haven't figured out is when resolving directly via IWindsorContainer (and not through IServiceProvider) on a new thread. ExtensionContainerScopeAccessor.GetScope still throws "No scope available"

@alkampfergit
Copy link

I still ask to check for our pr #668 that will fix this and also add support for .NET 8 keyed services. If it is possible could you check code of pr #668 to verify if this fixes null scope in your situation? I'm asking because the support for .NET 8 branch is opened from a long time and I'd like it to be closed if possible (we are in production with that version using a private package source and I'd really like to move again on supported nuget packages)

@ltines
Copy link
Contributor Author

ltines commented May 22, 2024

@alkampfergit i had a quick look, but need to read a lot about semantics (especially keyed / not keyed). I would like to implement it using named instances in Castle so we don't have to introduce new concepts.

@alkampfergit
Copy link

Remember that if you are moving to dependency injection version 8.0.0 without keyed service support the adapter does not works . The problem presents when any library starts using keyed service and new resolution semantic, so you got weird error.

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

Successfully merging this pull request may close these issues.

NET 6.0 ForcedScope Failed with "No Available Scope" on GET request
2 participants