Abp 调用仓储时报错:无法访问已处理的上下文实例

1.报错

One or more errors occurred. (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: 'WMSDbContext'.)

2.解决方法:

2.1 设置生命周期函数 ISingletonDependency或其他的生命周期函数

2.2 实现的接口方法添加工作单元属性 [UnitOfWork],并且把接口方法添加 virtual 修饰符

2.3 注意,如果是异步,要加上对应的async和await 

猜你喜欢

转载自blog.csdn.net/weixin_39237340/article/details/126437876
ABP
今日推荐