不能调试使用的Process.Start项目启动() [英] Can not debug a Project started using Process.Start()

查看:743
本文介绍了不能调试使用的Process.Start项目启动()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个解决方案两个C#WinForm的项目,让我们称之为A和B.项目A通过调用启动进程B像下面

I have two C# WinForm projects in the same solution lets call them A and B. Project A starts Process B via a call like below

ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Task.EXEFilename;
psi.WorkingDirectory = Path.GetDirectoryName(Data.EXEFilename);
Process.Start(psi);



进程B被正确启动。我想调试进程B,而我调试答:我认为把一个破发点,在B就足够了,但它从来没有击中。我已验证了启动过程是B.我不应该做附着在这种情况下,处理从A切换调试的B中的bin / debug文件夹?

The process B is started correctly. I wanted to debug the process B while I am debugging A. I thought putting a break point in the B would be enough but it is never hit. I have verified that process that is started is in the bin/debug folder of the B. I should not be doing attached to process in this case to switch debugging from A to B ?

推荐答案

在第二个项目有它检查其命令行参数,如果它看到的东西像 - 调试在作为传递第一个参数的第二个程序启动调试器本身

In the 2nd project have it check its command line arguments, if it sees something like --debug was passed in as the first argument the 2nd program launches the debugger itself

private static void Main(string[] args)
{
    //If no debugger is attached and the argument --debug was passed launch the debugger
    if (args.Length == 1 && args[0] == "--debug" && Debugger.IsAttached == false)
        Debugger.Launch();

    //(snip) the rest of your program

}


$其余b $ b

当你这样做,你会得到一个对话框,让你选择要打开Visual Studio中的一个新副本,或只是用你已经打开副本。

When you do this you will get a dialog window that will allow you to choose to open a new copy of Visual Studio or just use your already open copy.

您也可以把孩子过程中的图像文件执行Options注册表项

You can also put the child process in the Image File Execution Options registry key.

这篇关于不能调试使用的Process.Start项目启动()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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