-
-
Notifications
You must be signed in to change notification settings - Fork 69
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: Resolution failed with error: Cannot access a disposed object. #290
Comments
I'm starting to investigate. I think somehow our container seems to be getting disposed and we wind up using it afterwards. We're using WebApi We have an IDependencyScope created by an IDependencyResolver. Here's the set up. In global.asax.cs in Application_Start we call this.
UnityDependencyResolver.cs looks like this.
and finally UnityDependencyScope.cs looks like this.
We haven't seen any issues in our previous version of Unity which was version 5.8.11. We are now using 5.11.7 and seeing the issue. If anyone can give me some clues on where to look that would be great. I need to get this resolved ASAP and I suspect I'm going to have a difficult time recreating this in lower environments since it seems very intermittent. It must be a timing issue. I wonder if we have issues with Async. Maybe the Dispose is getting called prior to completing an async operation? |
It is known issue and will be fixed in v6. I'd suggest to go back to working version for now. |
@ENikS , Thanks. Any idea on how far I need to go back? I made lots of changes to support 5.11.7, would hate to go all the way back to 5.8.11. |
Look at this issue, this been going on for a while. Check the other issues in that repo. |
I was looking through your source and found this WebApi resolver. It seems to be setup different from mine. It has a SharedDependencyScope that doesn't dispose the container. Can you explain why this is different and do you think this is the correct way to use it? Also, I'm using .Net Framework 4.7.2, not .Net Core.
|
It's possible the reason mine is different is that I want to create a new child container for each request. That way I can have a HeirarchialLifetime Manager that will be per request. |
Perhaps this is the reason? public void Dispose()
{
// NO-OP, as the container is shared.
} |
I just did a production release and I'm getting intermittent errors like this.
Resolution failed with error: Cannot access a disposed object.
Object name: 'Container[546].Child[0]'.
For more detailed information run Unity in debug mode: new UnityContainer().AddExtension(new Diagnostic())
It's happening when trying to Resolve an type that is not based on an interface and is not registered. I'm calling Container.Resolve()
Any idea. It's not even a disposable object. It does not implement IDisposable.
It's looking like I'm going to rollback by deployment until I get a better understanding of what's going on, but any help would be appreciated.
The text was updated successfully, but these errors were encountered: