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

Encountering IAsyncDisposable Error #577

Closed
Mike-E-angelo opened this issue Oct 10, 2022 · 3 comments · Fixed by seesharper/LightInject.Microsoft.DependencyInjection#200
Closed

Comments

@Mike-E-angelo
Copy link

Thank you again for adding IAsyncDisposable support. However, I am now getting a weird exception on disposing of Blazor controls:

System.InvalidOperationException: The type DragonSpark.Presentation.Environment.Browser.Document.FocusedElement only implements `IAsyncDisposable` and can only be disposed in an asynchronous scope started with `BeginScopeAsync()`
   at void LightInject.Scope.Dispose()
   at void LightInject.Microsoft.DependencyInjection.LightInjectServiceScope.Dispose()
   at ValueTask Microsoft.Extensions.DependencyInjection.AsyncServiceScope.DisposeAsync()
   at ValueTask DragonSpark.Composition.Construction.ServiceScopeFactory+Scope.DisposeAsync() in D:/a/1/s/Framework/DragonSpark.Composition/Construction/ServiceScopeFactory.cs:line 35

Note that the above code can be found here:
https://github.com/DragonSpark/Framework/blob/master/DragonSpark.Composition/Construction/ServiceScopeFactory.cs

The first thing that catches my eye is a reference to BeginScopeAsync which I do not see anywhere.

The other issue is that while LightInject.Scope is now IAsyncDisposable it appears that LightInject.Microsoft.DependencyInjection.LightInjectServiceScope is not and still only implements IDisposable only.

Anyways, I may be confused here but wanted to start the confirmation and see if there is something I am overlooking/misunderstanding. Thank you for any assistance/consideration.

@Mike-E-angelo
Copy link
Author

Excellent, thank you @seesharper it is appreciated. Any chance you can update LightInject.Microsoft.Hosting to point to this new version? It is what I am using to pull in all your magic :D

@seesharper
Copy link
Owner

@Mike-E-angelo LightInject.Microsoft.Hosting 1.5.0 should pull in everything you need 👍😃

@Mike-E-angelo
Copy link
Author

Confirmed @seesharper! Thank you very much 🙏

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