What does "Contract can't be in try block" mean?
Posted
by MatthewMartin
on Stack Overflow
See other posts from Stack Overflow
or by MatthewMartin
Published on 2010-05-21T15:51:34Z
Indexed on
2010/05/21
16:00 UTC
Read the original article
Hit count: 194
c#
|code-contracts
I'm using the 3.5 library for microsoft code contracts
public object RetrieveById(int Id)
{
Contract.Ensures(newObject != null, "object must not be null");
return newProject;
//No error message if I move the Contract.Ensures to here
//But it isn't asserting/throwing a contract exception here either
}
I get the compiler message: "Error 18 Contract section within try block in method 'Controller.RetrieveById(System.Int32)'
© Stack Overflow or respective owner