为了账号安全,请及时绑定邮箱和手机立即绑定

.net core异常:"Cannot access a disposed object"

.net core异常:"Cannot access a disposed object"

陪伴而非守候 2018-07-31 07:10:30
在一个asp.net core webapi项目的集成测试中遭遇下面的异常,请问如何解决?Cannot access a disposed object. A common cause of this error is disposing a context 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, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. [xUnit.net 00:00:03.2384249]       Object name: 'EfUnitOfWork'. [xUnit.net 00:00:03.2425838]       Stack Trace:依赖注入用的是 services.AddScoped
查看完整描述

1 回答

?
阿波罗的战车

TA贡献1862条经验 获得超6个赞

翻转控制器已经释放了目标对象了,参考修改对象生命周期的方法


查看完整回答
反对 回复 2018-08-25
  • 1 回答
  • 0 关注
  • 3758 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号