【问题标题】:Doing "project>Debug>Start new instance" of an another project in the same solution through c# code通过 c# 代码在同一解决方案中执行另一个项目的“项目>调试>启动新实例”
【发布时间】:2013-12-16 10:14:41
【问题描述】:

有没有办法做到这一点,visual studio“project>Debug>Start new instance。”

通过c#代码做到这一点?

我的意思是通过第一个项目中的函数启动示例解决方案中的第二个项目。

比如说,我有 2 个项目,

                #project 1

                #project 2, both are in same solution.

#project 1中有一个函数,

说,

          public void startproject2()

            {
             //code for doing "project>Debug>Start new instance" #project 2

             }

有没有办法通过c#代码做到这一点?

【问题讨论】:

  • 那么你的意思是作为两个可执行文件运行?所以说你的两个项目都是表格,你要打开两个表格吗?如果是这样,您可以编译第二个项目并使用Process.Start("path/to/the/compiled/exe") 运行
  • 我在#project 1中有一个函数需要启动项目2,然后,#project 2中的一个函数被命中,#project 2中的一个函数被命中,将数据作为参数传递给a #project1 中的函数
  • 在这种情况下,听起来您实际上想考虑将项目 2 设为库项目,然后您可以像其他库一样将其包含到项目 1 中,并从您的第一个项目中调用其中的函数.

标签: c# .net visual-studio-2010 visual-studio visual-studio-2012


【解决方案1】:

听起来你想同时调试 2 个项目。

为此,只需右键单击解决方案并选择Set Startup Projects...。 如果您按 F5 进行调试,您可以在此处选择应该启动和调试的项目。

【讨论】:

  • 我希望项目 2 中的该功能仅在特定事件中启动
  • 这行不通,而且说真的,我想不出任何你需要它的场景。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-14
  • 1970-01-01
  • 1970-01-01
  • 2022-11-30
相关资源
最近更新 更多