Visual Studio:生成进程时自动附加到进程 [英] Visual Studio: auto attach to a process when the process is spawned

查看:220
本文介绍了Visual Studio:生成进程时自动附加到进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在生成过程中附加一个进程(a.exe),是否可以用VS?我只知道进程的名称。实际上我想要完成的是在C#代码中设置一个断点,但代码属于另一个可以由当前运行的应用程序(c.exe)启动的可执行文件。代码在初始化期间内,所以我不可能手动执行附件。

I want to attach to a process(a.exe) as soon as it is spawned, is it doable with VS? I only know the name of the process. Actually what I want to accomplish is set a breakpoint in c# code, but the code is belonging to another executable which will be launched by current running application(c.exe). The code is inside the initialize period so it is impossible for me to do the attach manually.

推荐答案

当我遇到这个情况之前(和我控制的两个进程),我发现一个体面的解决方法是调用 Debugger.Launch()在产卵过程的入口点。 VS将弹出一个对话框,让你附上这个过程。

When I've faced this situation before (and I controlled both processes), I found a decent workaround is to put a call to Debugger.Launch() in the spawning process' entry point. VS will then pop up a dialog box and let you attach to the process.

这篇关于Visual Studio:生成进程时自动附加到进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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