What is Microsoft.Contracts and where does it come from?

I have a custom SharePoint job that causes an error while trying to execute. When I look at the error, I see:

Could not load file or assembly 'Microsoft.Contracts, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 736440c9b414ea16' or one of its dependencies. The system cannot find the file.

I was looking for my solution and it is not mentioned anywhere. Where could this come from?

+6
source share
4 answers

Microsoft.Contracts ( CodeContracts ) is an assembly that contains methods that "provide a language-agnostic way of expressing assumptions about coding in .NET."

Perhaps some kind of external assembly is searching for this.

+4
source share

If you are using .NET 3.5 or earlier, you need to add a link to Microsoft.Contracts.dll installed under:
%PROGRAMFILES%/Microsoft/Contracts/PublicAssemblies

+3
source share

Microsoft.Contracts is the main build of the Microsoft Code Contracts system . If it is not used by your actual code, it could very well be used by the reference library.

In theory, you should be able to delete all the code associated with it, and your program should work the same. After all, this is just a way to practice and help with testing. In practice, I'm not sure ...

Code contracts provide an agnostic language for expressing coding assumptions in .NET programs. Contracts take the form of preconditions, post-conditions, and object invariants. Contracts act as validated documentation of your external and internal APIs. Contracts are used to improve testing through runtime verification, the inclusion of static contract verification and documentation generation. Code contracts bring the benefits of design by contract programming for all .NET programming languages. We currently provide three tools:

The full version is available only in VS 2010 Premium / Ultimate, but apparently you can get the standard version for other versions of VS.

+2
source share

You can find the library here C: \ Program Files \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0 \ mscorlib.dll

0
source share

All Articles