简体   繁体   English

Visual Studio 2012中的VSConstants

[英]VSConstants in Visual Studio 2012

I am moving a project from Visual Studio 2010 to Visual Studio 2012 and am getting compiler errors about VSConstants : 我正在将项目从Visual Studio 2010移动到Visual Studio 2012,并且我收到有关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. 我确保引用了Microsoft.VisualStudio.Shell,并且还尝试引用Microsoft.VisualStudio.Shell.11.0和Microsoft.VisualStudio.Shell.10.0。 I have checked that the .cs file is using the assembly as well ( using Microsoft.VisualStudio.Shell ). 我已经检查过.cs文件也在using Microsoft.VisualStudio.Shell程序集( using Microsoft.VisualStudio.Shell )。

Any ideas on how to get VSConstants in Visual Studio 2012? 有关如何在Visual Studio 2012中获取VSConstants任何想法? If not, is there an equivalent in Visual Studio 2012 that I could use? 如果没有,我可以使用Visual Studio 2012中的等价物吗? I'm currently using VSConstants.E_FAIL and VSConstants.E_NOINTERFACE . 我目前正在使用VSConstants.E_FAILVSConstants.E_NOINTERFACE

Thanks! 谢谢!

Make sure you have the VS 2012 SDK installed from http://www.microsoft.com/en-au/download/details.aspx?id=30668 确保从http://www.microsoft.com/en-au/download/details.aspx?id=30668安装了VS 2012 SDK

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 您需要添加C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VSSDK\\VisualStudioIntegration\\Common\\Assemblies\\v4.0\\Microsoft.VisualStudio.Shell.11.0.dll作为项目的参考

To use that assembly you will have to target the 4.5 framework. 要使用该程序集,您必须以4.5框架为目标。

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. 或者,我刚刚升级的项目...我需要做的就是将框架版本更改为4.5并删除它找不到的项目引用。 I had anticipated that ReSharper would point me at the new ones but it just built anyway. 我曾预料到ReSharper会把我指向新的但它无论如何都会建造。 Note, this was after I installed the SDK. 注意,这是在我安装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中试用Microsoft的“Designer View Over XML Editor”( http://code.msdn.microsoft.com/Designer-View-Over-XML-20a81f17 )时,我遇到了同样的问题。

Visual Studio 2012 upgraded the solution and its project. Visual Studio 2012升级了解决方案及其项目。 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. 事实证明,对于“Microsoft.VisualStudio.Shell.10.0”(不是“Microsoft.VisualStudio.Shell.11.0”,对新目标执行相同操作,但类似)的引用无法解决,因为它是为较新版本的.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". “C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319 \\ Microsoft.Common.targets(1578,5):警告MSB3274:无法解析主要参考”Microsoft.VisualStudio.Shell.10.0“,因为它已构建反对“.NETFramework,Version = v4.5”框架。这是一个比当前目标框架“.NETFramework,Version = v4.0”更高的版本。

Essentially the project upgrade left the project with the older version of .NET by mistake. 本质上,项目升级错误地将项目与旧版本的.NET一起离开了。 So I opened the project properties page, and changed it to .NET 4.5. 所以我打开了项目属性页面,并将其更改为.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. 在Visual Studio 2012中进行调试时,有两个相互冲突的XmlEditor版本。 The version referenced in the project was intended for Visual Studio 10.0. 该项目中引用的版本适用于Visual Studio 10.0。 So more versions changes were needed to get it to work properly. 因此需要更多版本更改才能使其正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM