SolutionContext.ConfigurationName设置返回E_FAIL [英] SolutionContext.ConfigurationName set returns E_FAIL

查看:97
本文介绍了SolutionContext.ConfigurationName设置返回E_FAIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在自定义项目中具有以下代码基于MPF for Projects-Visual Studio 2010:

 EnvDTE.Project dteProj = CurrentProject();
dteProj.ConfigurationManager.AddConfigurationRow("MyCustomConfig","Debug",false);
var solution = dteProj.DTE.Solution as EnvDTE90.Solution3;
foreach(solution.SolutionBuild.SolutionConfigurations中的EnvDTE80.SolutionConfiguration2 solConfig)
{
  foreach(solConfig.SolutionContexts中的EnvDTE.SolutionContext solContext)
  {
    如果(dteProj.UniqueName!= solContext.ProjectName)
      继续;

    //返回E_FAIL
    solContext.ConfigurationName ="MyCustomConfig";
  }
} 

为什么作业失败?从配置管理器"对话框的下拉列表中为项目选择项目配置的正确编程等效项是什么?

解决方案

简短答案:EnvDTE.Solution.SolutionBuild.ActiveConfiguration和EnvDTE.Project.ConfigurationManager.ActiveConfiguration

长答案:请阅读我的文章:

复杂的构建配置自动化模型(EnvDTE/EnvDTE80)
http: //msmvps.com/blogs/carlosq/archive/2008/08/29/the-convoluted-build-configuration-of-the-automation-model-envdte-envdte80.aspx

和:

复杂的构建配置自动化模型(EnvDTE/EnvDTE80)的图(第2部分)
http: //msmvps.com/blogs/carlosq/archive/2008/09/01/the-fiagram-of-convolulated-build-configuration-automation-model-envdte-envdte80.aspx


I have the following code in a custom project based on MPF for Projects - Visual Studio 2010:

EnvDTE.Project dteProj = CurrentProject();
dteProj.ConfigurationManager.AddConfigurationRow("MyCustomConfig", "Debug", false);
var solution = dteProj.DTE.Solution as EnvDTE90.Solution3;
foreach (EnvDTE80.SolutionConfiguration2 solConfig in solution.SolutionBuild.SolutionConfigurations)
{
  foreach (EnvDTE.SolutionContext solContext in solConfig.SolutionContexts)
  {
    if (dteProj.UniqueName != solContext.ProjectName)
      continue;

    //Returns E_FAIL 
    solContext.ConfigurationName = "MyCustomConfig";
  }
}

As you can see everything is pretty straight forward. I create a new configuration for my project and want to use it in a solution context. Setting the configuration name returns E_FAIL.

Why is the assignment failing? What is the correct programmatic equivalent for selecting a project configuration for a project from the drop down in the Configuration Manager dialog box?

Thanks

解决方案

Hi,

The short answer: EnvDTE.Solution.SolutionBuild.ActiveConfiguration and EnvDTE.Project.ConfigurationManager.ActiveConfiguration

The long answer: read my posts:

The convoluted build configuration automation model (EnvDTE/EnvDTE80)
http://msmvps.com/blogs/carlosq/archive/2008/08/29/the-convoluted-build-configuration-of-the-automation-model-envdte-envdte80.aspx

and:

The diagram of the convoluted build configuration automation model (EnvDTE/EnvDTE80) (Part 2)
http://msmvps.com/blogs/carlosq/archive/2008/09/01/the-fiagram-of-convoluted-build-configuration-automation-model-envdte-envdte80.aspx


这篇关于SolutionContext.ConfigurationName设置返回E_FAIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆