断言不变量的System.ExecutionEngineException [英] System.ExecutionEngineException on asserting broken invariant

查看:66
本文介绍了断言不变量的System.ExecutionEngineException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Contract.Invariant()中检查了System.ExecutionEngineException,当不满足不变量时。

I got System.ExecutionEngineException in Contract.Invariant() check when invariant is not satisfied.

推荐答案

是的,这是一条已知的错误信息。当.NET 4.0使用FailFast时,断言断言的情况就是如此,结果消息不是很有用。它应该只是默默地退出,但它不会。

Right, this is a known bad message. When .NET 4.0 uses FailFast as is the case when an assertion is aborted, the resulting message is not very helpful. It should just silently exit, but it doesn't.

你可以取消选中"断言合同失败"。在UI中,这将导致抛出异常而不是断言。

You can either uncheck the "assert on contract failure" in the UI, which will cause an exception to be thrown instead of an assert.

或者,您可以为此连接自己的失败方法(请参阅文档第7.1-7.7节)。

Alternatively, you can wire up your own failure methods (see the documentation Section 7.1-7.7) for this.

 


这篇关于断言不变量的System.ExecutionEngineException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆