Tools for Code Contracts

When you use code contracts, the first requirement is the System.Diagnostics.Contracts namespace, exposed by the Mscorlib.dll assembly. By the way, this is not enough to make your code take advantage of contracts. Although you never see this, Visual Studio invokes behind the scenes some command-line tools. This subsection provides basic information on these tools and on their purpose.

The Binary Rewriter

As you know, when you compile a .NET executable, the file is made of metadata and Intermediate Language. When you use contracts, especially for runtime checking, the Intermediate Language within an executable needs to be modified to recognize contracts. The edits are performed by the CCrewrite.exe tool that injects the ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.