0
votes

Is it possible to use Code Contracts in Dynamics CRM 2011 Workflows?
The Contract Entity has the same name as Contract in System.Diagnostics.Contracts, but code contracts can still be used like this

 System.Diagnostics.Contracts.Contract.Requires(i < 5);

I get this Warning:

Method 'CRV.AssociateEmail.Execute(System.Activities.CodeActivityContext)' overrides 'System.Activities.CodeActivity.Execute(System.Activities.CodeActivityContext)', thus cannot add Requires.

1

1 Answers

1
votes

This is not an issue in regards to CRM.

You are basically overwriting the Execute method of CodeActivity when you are creating a new workflow activity. You can't add contracts at this point.

See this question for a explanation: Why can't I add Contract.Requires in an overridden method? And for more details: http://stefanoricciardi.com/2009/07/17/code-contracts-and-inheritance/