本文主要是介绍abp EventBus实现订阅事件出现 Cannot access a disposed context instance,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
调试发现执行到这里就会抛出异常,db上下文已被释放
Cannot access a disposed context instance. A common cause of this
error is disposing a context instance that was resolved from
dependency injection and then later trying to use the same context
instance elsewhere in your application. This may occur if you are
calling ‘Dispose’ on the context instance, or wrapping it in a using
statement. If you are using dependency injection, you should let the
dependency injection container take care of disposing context
instances. Object name: 'xxxDbContext
解决方式
方法上添加 [UnitOfWork],方法添加 virtual 修饰符
这篇关于abp EventBus实现订阅事件出现 Cannot access a disposed context instance的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!