Home > Articles > Details

System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependecy injection and then later trying to use the same context instance elsewhere in your application. 

Question: How do you solve: "System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependecy injection and then later trying to use the same context instance elsewhere in your application. 

This may occur if you a are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using depedency injection, you should let the dependecy injection container take care of disposing context instances.

Object name: NameOfObject.


If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.


© 2022 - ErnesTech - Privacy