I get the following error when running Microsoft Code Contracts:
CodeContracts: Diagnostic: Failed to connect to any cache.
The user manual for Code Contracts states:
Cache results: Controls if the analysis results are cached. If checked, the analysis tries to avoid analyzing methods whose outcomes cannot possibly change (because no contracts, no code, and no relevant metdata has changed). Enabling this option allows for faster turn-around times if using the static checker repeatedly. To share the cache among multiple developers, use a SQL server and put the server name in the SQL Server conguration box in the UI. Note: the SQL server connection uses Windows authentication to log onto the server. Your developers will need the right to create and modify databases.
Find out the correct name of SQL server installed on your machine (note that "localhost" will not work; it has to be the actual machine name):
Right click on the project, select "Properties", go to the "Code Contracts" tab (down the bottom of the list), then, add your machine name:
This works for Release 1.5.60911.10 (Sep 11, 2013). Perhaps future versions of Code Contracts will attempt to connect to "localhost" and/or accept "localhost" in this box, and/or automatically detect SQL Server 2012.
In my particular case, I didn't have "(localdb)\V11.0" installed; if I had installed this then it would have worked out of the box (it must be defaulting to this internally).
Just uncheck the "Cache Results" option under the "Static Analysis" section of "Code Contracts" property page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With