VS 2012 installation does not show code contracts tab
-
2012年6月3日 上午 07:33How do I get code contracts to appear in VS2012?
所有回覆
-
2012年6月3日 上午 07:56
Hmm - perhaps if I read the forum.
A new release of Code Contracts 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).
- 已標示為解答 Brett Shearer 2012年6月3日 上午 07:56
- 已取消標示為解答 Brett Shearer 2012年6月3日 上午 08:00
-
2012年6月3日 上午 08:01
Have just tried and no cigar...
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC>devenv /setup
did not add the tab to VS2012 RC.
-
2012年6月3日 上午 08:17
Just posting to confirm that the tab does not show and this step does not solve the issue.Have just tried and no cigar...
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC>devenv /setup
did not add the tab to VS2012 RC.
-
2012年6月4日 上午 06:26Same for me. The tab does not appear.
-
2012年6月4日 下午 10:51
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
-
2012年6月5日 上午 12:20
I did forget to run as admin, but after trying still fails.
Can anyone advise which registry setting controls and I can check directly for that.
-
2012年6月5日 上午 01:59Make sure you're running devenv.exe, not devenv.com - I made that mistake my first attempt.
-
2012年6月5日 上午 05:57
No avail. Tried even to reinstall CC, but the tab is still missing.
Btw "devenv.com /setup" starts "devenv.exe /setup" so it should be the same.
-
2012年6月12日 上午 10:28Worked a charm, thanks!
-
2012年7月10日 下午 12:37Just for clarity - I have a clean installation of VS 2012 RC (side-by-side with VS 2010). Is it your setup the same? Or have you upgraded to RC from beta?
-
2012年7月12日 下午 11:03
Yes - I am running VS 2010 and VS2012RC side by side. The RC is the first 2012 my machine has seen.
Attempted another devenv /setup but has not resolved.
-
2012年7月13日 上午 03:29
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? :)
-
2012年7月13日 上午 07:34
I have tried "devenv.exe /setup" again; no avail.
Maybe there is some difference between our systems configurations we've missed so far.
My system:
- Win7 SP1 x64 Ultimate Czech.
- VS 2010 SP1 (10.0.40219.1) Premium English.
- VS 2012 RC (11.0.50626.1) Premium English.
-
2012年7月13日 下午 03:37
Well, bummer. That's all I got. Yeah I guess just chalk it up to some sort of subtle system difference. Perhaps a language difference? I'm running:
- Win7 SP1 x64 Ultimate English
- VS 2010 SP1 (10.0.40219.1) Ultimate English
- VS 2012 RC (11.0.50626.1) Ultimate English
-
2012年7月15日 上午 10:09
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
-
2012年7月15日 下午 03:56
@_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).
@Brett Shearer: What is your system configuration?
-
2012年7月18日 下午 03:01
@_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).
@Josef:
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. -
2012年7月19日 上午 01:44
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.- 已編輯 Jorgy343 2012年7月19日 上午 01:46
- 已提議為解答 Josef Bláha 2012年7月23日 上午 05:19
-
2012年7月23日 上午 05:17
@_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
-
2012年7月23日 下午 01:26Perfect. I think the restart is the missing puzzle piece since that is exactly what did it for me. Hopefully this thread will help others and that it will be fixed when RTM comes out.
-
2012年9月5日 上午 07:30
For Visual studio 2012 in Window 7 the command "devenv /setup" worked.
-
2012年9月6日 下午 01:00The restart is the key. Confirmed.
-
2012年9月12日 下午 04:36擁有者
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 Barnett
- 已提議為解答 Mike BarnettMicrosoft Employee, Owner 2012年9月12日 下午 04:36
-
2012年12月5日 下午 09:23
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)

