如果startupapplication是可执行文件,请设置启动参数. [英] Setting start arguments if startupapplication is an executable.

查看:94
本文介绍了如果startupapplication是可执行文件,请设置启动参数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:我正在编写一个扩展,其中的一个元素是调试选项.如果选择了debug-option,则扩展名必须将.exe作为启动应用程序加载(我已经使用dte2成功完成了此操作).之后,它必须启动调试(在 活动的vs2010),并具有基于树状视图中检查的项目的启动参数.在这里,我遇到了障碍.

Problem: I am writing an extension in which one of the elements is a debug option. If the debug-option is chosen then the extension must load a .exe as startup application (This I have done succesfully using dte2). following that it must launch a debug (in the active vs2010) with startup arguments based on items checked in a treeview. Here I've hit a snag.

尝试失败的解决方案:

prj.ConfigurationManager.ActiveConfiguration.Properties返回null,因此无法以这种方式设置开始参数

prj.ConfigurationManager.ActiveConfiguration.Properties gives back null, so unable to set startarguments that way

prj.properties不包含startarguments,仅文件名,路径...

在寄存器中设置调试键不是 选项,因为我还必须能够在不调试的情况下运行exe.

setting debug-key in register isn't an option because I must also be able to run the exe without debug.

启动 因为也无法选择进程和调试器,因为我无法更改exe以便等到它被处理后再继续操作,并且同时代码仍在运行.

launching as process and ataching to debugger is also not an option, because I can't change the exe to wait until it's atached before proceding, and in meantime code is still running.

btw 可执行文件是一个单元测试应用程序,它会根据启动参数加载必要的dll和用这些dll编写的预测试.因为选项几乎没有限制,所以我无法预定义它们.

btw the executable is a unittest application which loads nescessary dll's and preforms test written in these dll's based upon the startarguments. as the options are almost unlimeted I'm not able to predefine them.

schout 

schout 

推荐答案

你好,

prj.ConfigurationManager.ActiveConfiguration.Properties不应返回null.对于诸如解决方案项"之类的项目,ConfigurationManager可以为null.伪项目,但不适用于常规C#或VB.NET.

prj.ConfigurationManager.ActiveConfiguration.Properties shouldn't return null. The ConfigurationManager can be null for projects like the "Solution Items" pseudo-project, but not for a regular C# or VB.NET.

此宏适用于VB.NET或C#项目的解决方案:

This macro works for a solution with a VB.NET or C# project:

  子ConfigProperties()

       MsgBox(DTE.Solution.Projects.Item(1).ConfigurationManager.ActiveConfiguration.Properties.Item(1).Name)

   结束子

    Sub ConfigProperties()

        MsgBox(DTE.Solution.Projects.Item(1).ConfigurationManager.ActiveConfiguration.Properties.Item(1).Name)

    End Sub

在您的情况下,哪一部分为空? prj? ConfigurationManager? ActiveConfiguration?或属性?

In your case, which part is null? prj? ConfigurationManager? ActiveConfiguration? or Properties?


这篇关于如果startupapplication是可执行文件,请设置启动参数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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