c# - 如何获取当前的 Active Solution Platform 名称以用于 Visual Studio 加载项? (C#)

标签 c# visual-studio-2010 visual-studio add-in

我正在创建一个用 C# 编写的 Visual studio 插件,允许用户将他们的代码发送到远程 PC 进行解析。该过程将根据所使用的 Active Solution Platform 而有所不同。

我希望插件能够获取当前的 Active Solution Platform,以便正确处理用户代码。

我尝试了以下方法:

try    
{
SolutionBuild builder = applicationObject.Solution.SolutionBuild;
SolutionConfiguration2 config;
config = (SolutionConfiguration2)builder.SolutionConfigurations.Item(1);
MessageBox.Show("The platform name of 
the solution configuration is: " + config.PlatformName);
}
catch(SystemException ex)
{
   MessageBox.Show(ex.ToString());
} 

然而,这总是返回列表中的第一个平台,而不是当前平台。

最佳答案

要获取事件的解决方案配置和平台,请使用此

string active_config = (string)addin_inst.DTE.Solution.Properties.Item("ActiveConfig").Value;

这将得到一个形式为“Debug|Win32”的字符串。该平台将在'|'之后

关于c# - 如何获取当前的 Active Solution Platform 名称以用于 Visual Studio 加载项? (C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11868290/

相关文章:

c# - 如何将 CSV 文件读入 .NET 数据表

c# - 带有 FileUpload 控件的 Gridview

c# - 在另一台机器上运行我的 Asp.Net Web 应用程序

visual-studio - 在 Visual Studio 命令提示符中更改分区

c++ - 在 OpenCV 中自动检测和裁剪 ROI

visual-studio - .NET 核心 3.0 : ASPNETCORE_ENVIRONMENT has value Development on publish

c# - 从 MVC Web 项目发送 Apple 推送通知

c# - 对现有 ASP.NET MVC Controller 进行单元测试

visual-studio - 从 VSPackage 类导入 MEF 组件

c# - 懒惰<T> : "The function evaluation requires all threads to run"