I am moving a project from Visual Studio 2010 to Visual Studio 2012 and am getting compiler errors about VSConstants
:
Error 16 The name 'VSConstants' does not exist in the current context
I have ensured that Microsoft.VisualStudio.Shell is referenced and have also tried referencing Microsoft.VisualStudio.Shell.11.0 and Microsoft.VisualStudio.Shell.10.0. I have checked that the .cs file is using the assembly as well (using Microsoft.VisualStudio.Shell
).
Any ideas on how to get VSConstants
in Visual Studio 2012? If not, is there an equivalent in Visual Studio 2012 that I could use? I'm currently using VSConstants.E_FAIL
and VSConstants.E_NOINTERFACE
.
Thanks!
Make sure you have the VS 2012 SDK installed from http://www.microsoft.com/en-au/download/details.aspx?id=30668
You need to add C:\Program Files (x86)\Microsoft Visual Studio 11.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.11.0.dll
as a reference to the project
To use that assembly you will have to target the 4.5 framework.
Alternatively, The project I just upgraded ... all I needed to do was to change the framework version to 4.5 and delete the project references it couldn't find. I had anticipated that ReSharper would point me at the new ones but it just built anyway. Note, this was after I installed the SDK.
When I tried out Microsoft's "Designer View Over XML Editor" (http://code.msdn.microsoft.com/Designer-View-Over-XML-20a81f17) in Visual Studio 2012, I had the same problem.
Visual Studio 2012 upgraded the solution and its project. No problem there. However, the solution would not build. It turned out that the reference to "Microsoft.VisualStudio.Shell.10.0" (not "Microsoft.VisualStudio.Shell.11.0", which would do the same thing for newer targets, but similar) could not be resolved because it was built for a newer version of .NET. It said that in the output window as well:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1578,5): warning MSB3274: The primary reference "Microsoft.VisualStudio.Shell.10.0" could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".
Essentially the project upgrade left the project with the older version of .NET by mistake. So I opened the project properties page, and changed it to .NET 4.5. That made the solution build.
However, there were other issues once it was built. When debugging it in Visual Studio 2012, there were two conflicting versions of XmlEditor. The version referenced in the project was intended for Visual Studio 10.0. So more versions changes were needed to get it to work properly.
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