What is Microsoft.Contracts and where is it coming from?
I have a custom SharePoint job that is erroring out when it tries to run. When I look at the e开发者_如何学编程rror 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 specified.
I've searched my solution and there is no reference to this anywhere. Where could this be coming from?
Microsoft.Contracts (CodeContracts) is the assembly in which are contained the methods that "provides a language-agnostic way to express coding assumptions in .NET programs".
Maybe some external assembly is searching this one.
If you are using .NET 3.5 or earlier, you need to add a reference to Microsoft.Contracts.dll
that is installed under:
%PROGRAMFILES%/Microsoft/Contracts/PublicAssemblies
Microsoft.Contracts
is the main assembly of the Microsoft Code Contracts system. If its not used by your actual code, it could well be used by a referenced library.
In theory you should be able to remove all code related to it and your program should run the same. It is after all just a way of enforcing practices and helping with testing. In practice, I'm not so sure...
Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs. The contracts take the form of pre-conditions, post-conditions, and object invariants. Contracts act as checked documentation of your external and internal APIs. The contracts are used to improve testing via runtime checking, enable static contract verification, and documentation generation. Code Contracts bring the advantages of design-by-contract programming to all .NET programming languages. We currently provide three tools:
The full version is only available in VS 2010 Premium/Ultimate, but apparently you can get a "standard edition" for other versions of VS.
You can find the library here C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll
精彩评论