Hmm - perhaps if I read the forum.
A new release of is now live. Besides some small bug fixes, this release provides support for Dev11. NOTE: In order to see the Code Contracts pane in Dev 11, you must manually run "devenv /setup" from a command prompt (either a Visual Studio command prompt or else one that has a path set so "devenv.exe" (for Dev11) is found).
It works. Perhaps you're not running in Admin mode, or perhaps it's the wrong path. Here's what worked for me:
- Close Visual Studio.
- Launch a command prompt as Administrator.
- Browse to "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE" (default install path on my machine - tweak it for your own situation).
- Run "devenv.exe /setup".
- Open a project in Visual Studio - Code Contracts tab appears.
- 已提議為解答 Ralias 2012年8月16日 上午 10:48
I also have 2010 and 2012RC side-by-side. Never installed any other version of 2012.
I also ran "denenv /setup" at first and it didn't work. But then I specifically ran "devenv.exe /setup", and the tab appeared.
Maybe it still won't fix it for you; but you know ... worth a shot, right? :)
Tab shows up for me, but my setup is slightly different.
Here's the steps I took after downloading Code Contracts installer:
- Closed all instances of VS2012 RC (make sure there aren't any stuck devenv processes still open in Task Manager)
- Opened VS2012 x86 Native Tools Command Prompt (opened as Administrator)
- Typed cd "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC"
- Typed devenv /setup
- Waited a little bit as it did something, then the command prompt returns (without letting you know anything happened)
- Opened VS2012 RC (opened as Administrator)
- Opened an existing project and checked the Properties to see the Code Contracts tab
My test system:
- Windows 8 Release Preview (English)
- VS 2012 RC (11.0.50626.1) Premium English.
- No other installations of VS
Maybe it depends which Command Prompt you use to install Code Contracts. x86 Native Tools Command Prompt vs. x64 Native Tools Command Prompt?
- 已編輯 _smickle_ 2012年7月15日 上午 10:10
@_smickle_: Tried your steps, but it does not help. The choice of command prompt would not change the result though, the devenv.exe is still the same (per VS installation).
Do you have the Code Contracts extension installed for VS2010 as well? Just curious if there is a conflict there. Also, which version of the .NET Framework is your project targeting? I happen to be targeting version 4.0. Below is a little detail I found on pg.24 of the Code Contracts documentation about the tab in VS. This all might be a conflict with some shared reference designer file(s) between VS2010 and VS2012, which one(s), I don't know. The documentation is located here: C:\Program Files (x86)\Microsoft\Contracts\Documentation\
On a different machine in the past, Windows 7 Enterprise, I had the tab missing from VS2010 after installation. This machine had VS2008 and VS2010 side-by-side. I had to uninstall the existing version of Code Contracts first, then reinstall the one for VS2010, then run the devenv /setup with elevated permissions again for it to show up. Another thing to note in my situation is that Visual Studio was installed by my account, a domain account which is in the Administrators group on the machine.
From the Code Contracts documentation (pg.24). Not saying this will help, but sheds some light on how using Code Contracts with .NET 4.0 implicitly references mscorlib for the namespace. Different for pre-4.0.
6 Visual Studio Integration
When the managed contracts plugin is installed, C# and VB projects within Visual Studio are augmented
with an extra property pane entitled \Code Contracts", as shown in Figure 3. This pane provides configu-
ration specific options for enabling runtime contract checking, as well as static contract checking.
If you are using contracts with a target platform of 4.0 or later and you are referencing (implicitly)
mscorlib.dll, then the Contract class appears in the System.Diagnostics .Contracts namespace. If you are using a
pre-4.0 target platform, you need to add a reference to the Microsoft .Contracts. dll library. The library should
appear under the .NET tab when adding project references.
I had the same exact issue. I have VS2010 SP1 Ultimate installed and I had code contracts installed with it. I just installed VS2012 RC Ultimate ran the devenv /setup command using the VS2012 x86 command line tool in administrative mode. Didn't work. I then tried the next most logical step: uninstall code contracts, restart, re-install, run devenv /setup like I said previously. Now it works perfectly.
Hopefully this works for everyone else having this issue. If anyone wants more detailed information, just say.Edit: I just noticed the post above me also states that this fixed the issue with VS2008 and VS2010. This is probably going to be the correct way of fixing this issue.
@_smickle_: Yes, I've used CC in VS2010 before. All my current projects are targetting .NET 4. What do you mean by "reinstalling CC for VS2010"? I have no choice for which VS to install CC in the setup. Have you?
I've finally made it work. I performed the steps I already done before (reinstall CC and run /setup) but this time I've restarted the computer after uninstalling CC. Perhaps that made the difference.
Now I got the CC tab. Albeit the VS now shows StanPackage error when loading solution, however this is a different case :)
- 已提議為解答 Josef Bláha 2012年9月6日 下午 01:06
We have just put out a new release (v1.4.50910.0) that should fix all VS2012/Code Analysis problems. Please try it and let us know if it doesn't work for you. Please do *not* run "devenv /setup" manually after installing -- that is now done automatically as part of the installation process.
- 已提議為解答 Mike BarnettMicrosoft employee, Owner 2012年9月12日 下午 04:36
For the love of all that is holy, *please* consider just including CC in VS in the future. It was somewhat understandable to have an add-on and a ridiculous install process for 2010, as it was new, but this is a few years later, so you have had plenty of time to integrate it into the IDE. (the entire Win8 wave has been a development and user nightmare for me, and having to go in and fiddle with every single extension to get my solution to build again is incredibly frustrating)