gpt4 book ai didi

c# - 如何在 Visual Studio 2010 中调试从另一个进程启动的 C# .NET 应用程序

转载 作者:太空狗 更新时间:2023-10-29 22:08:34 27 4
gpt4 key购买 nike

我有一个用 C# 编写的 .NET GUI 应用程序和一个 PDF 打印机。 PDF 打印机有一个字段,您可以在其中设置启动外部应用程序的命令。

在这种情况下,我可以使用这台打印机打印文档,打印机以生成的 PDF 文件的文件路径作为参数启动我的 EXE 文件。当我的应用程序从打印机启动时,如何调试它?

在 Visual Studio 2010 中,我可以为命令行参数设置调试信息,而且效果很好。但是,如果应用程序是从打印机启动的,则该应用程序无法正常工作。因此,我想在从打印机启动时调试我的应用程序。我怎样才能做到这一点?是否有在 Debug模式或类似模式下启动 EXE 文件的参数?

最佳答案

尝试附加到进程:

http://msdn.microsoft.com/en-us/library/c6wf8e4z.aspx

To attach to a running process 1.On the Debug menu, select Attach to Process. If no project is open, select Attach to Process on the Tools menu.

2.In the Attach to Process dialog box, find the program that you want to attach to from the Available Processes list.

a.If the program that you want to debug is running on another computer, you must first select the remote computer. For more information, see How to: Select a Remote Machine.

b.If the process is running under a different user account, select the Show processes from all users check box.

c.If you are connected through Remote Desktop Connection, select the Show processes in all sessions check box.

3.In the Attach to box, make sure that the type of code you will debug is listed. The default Automatic setting tries to determine what type of code you want to debug. If the automatic setting is not appropriate:

a.Click Select.

b.In the Select Code Type dialog box, click Debug these code types and select the types to debug.

c.Click OK.

4.Click Attach.

The Available Processes list is displayed automatically when you open the Processes dialog box. Processes can start and stop in the background while the dialog box is open. However, the contents are not always current. You can refresh the list at any time to see the current list of processes by clicking Refresh.

You can be attached to multiple programs when you are debugging, but only one program is active in the debugger at any time. You can set the active program in the Debug Location toolbar or the Processes window. For more information, see How to: Set the Current Program.

All Debug menu execution commands affect the active program. You can break any debugged program from the Processes dialog box or break all attached programs from the Debug menu. For more information, see How to: Break Execution.

关于c# - 如何在 Visual Studio 2010 中调试从另一个进程启动的 C# .NET 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6074121/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com