1

Sometimes when debugging with my application I encounter Contract.Requires() failing due to the condition its evaluating returning false (all good so far). However, if I click the Abort button webserver crashes and I get the message: "... has encountered a problem and needs to close ...". Two questions:

  1. Is this the expected behaviour?
  2. If not, what should be the behaviour?
Ɖiamond ǤeezeƦ
  • 3,223
  • 3
  • 28
  • 40

1 Answers1

1

Go to CodeContracts section in your project settings

enter image description here

And uncheck the "Assert on Contract Failure" checkbox in "Runtime checking" section

Dima Pasko
  • 1,170
  • 12
  • 20
  • Thanks Dima, this avoids the problem by changing the default behaviour of Code Contracts from showing an Assert dialog to generating exceptions. So by doing this I can avoid the problem completely. However, it doesn't answer my question regarding the effect of Abort. – Ɖiamond ǤeezeƦ Jan 16 '12 at 10:27