由于单元测试中使用以下代码做数据库UNDO事务处理,运行时提示

上下文“0x20b1a0”已断开连接。正在从当前上下文(上下文 0x20ac98)释放接口。这可能会导致损坏或数据丢失。要避免此问题,请确保在应用程序全部完成 RuntimeCallableWrapper (表示其内部的 COM 组件)之前,所有上下文/单元都保持活动状态。       

[TestInitialize()]
        public void MyTestInitialize()
        {
            ServiceConfig config = new ServiceConfig();
            config.Transaction = TransactionOption.RequiresNew;
            ServiceDomain.Enter(config);
        }
        //
        // 在每个测试运行完之后,使用 TestCleanup 来运行代码
        [TestCleanup()]
        public void MyTestCleanup()
        {

            if (ContextUtil.IsInTransaction)
            {
                ContextUtil.SetAbort();
            }
            ServiceDomain.Leave();
        }

相关文章:

  • 2021-05-26
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
猜你喜欢
  • 2021-05-17
  • 2021-07-29
  • 2021-07-30
  • 2022-02-28
  • 2021-11-29
相关资源
相似解决方案