以下代码:
Contract.Requires<ArgumentException>(command != null, Resources.Messages.CommandNotSpecified);
来电
Contract.AssertMustUseRewriter (ContractFailureKind kind, System.String message)
如果您使用的是 Visual Studio,这似乎是由于未将代码合同配置为使用运行时合同检查造成的。
文章@ http://devjourney.com/blog/code-contracts-part-2-preconditions/暗示在没有配置运行时检查的情况下生成的代码是:
public static void Requires<TException>(bool condition)
where TException: Exception
{
AssertMustUseRewriter(ContractFailureKind.Precondition, "Requires<TException>");
}
有人知道在 MonoDevelop 中该做什么以使合同按预期工作吗?
我得到的确切例外是:
2012-11-13 23:33:24.815 StickX[339:c07] mvx: Diagnostic: 34.46 Exception masked NotImplementedException: The requested feature is not implemented.
at System.Environment.FailFast (System.String message) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Environment.cs:821
at System.Diagnostics.Contracts.Contract.AssertMustUseRewriter (ContractFailureKind kind, System.String message) [0x00011] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Diagnostics.Contracts/Contract.cs:83
at System.Diagnostics.Contracts.Contract.Requires[ArgumentException] (Boolean condition, System.String userMessage) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Diagnostics.Contracts/Contract.cs:271