停止调试事件在C# [英] Stop Debugging Event in C#

查看:86
本文介绍了停止调试事件在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在任何出口执行命令,即使是在任何退出中执行命令用户是开发人员,然后点击Visual Studio上的停止调试按钮。



我尝试使用

  Application.ApplicationExit + = new EventHandler(this.OnApplicationExit); 

但它不起作用。可能我错了,不是事件。



我使用Winforms而不是,在表单关闭不能是事件。



我正在使用Visual Studio 2005 Net Framework 2.0(按客户要求),但仅供参考。



也许我可以重写这个?:

  public static void Exit(); 


解决方案

问题是停止调试功能将停止该应用程序完全如此,因此该应用程序中的不再代码将会运行。



您实现此目的的唯一方法是观察被调试的进程



根据[MSDN]:


如果从Visual Studio启动程序
,则停止调试将终止正在调试的进程。


但是可能可以使用 visual studio加载项


How or where can I run a command when the application closes, even if is a debug stop?

I need to perform a command in any exit, even if the user is a developer and click on "stop debugging" button on Visual Studio.

I try with

Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

but it doesn't work. Maybe I'm wrong or is not the event.

I'm using Winforms and not, on Form Close can't be the event.

I'm using Visual Studio 2005 Net Framework 2.0 (by client requirement), but is just for information.

Maybe can I rewrite this?:

public static void Exit();

解决方案

The problem is the "stop debugging" function will halt the application entirely - so no more code within that application will run.

Your only way of achieving this would be to watch the process being debugged externally and execute the code if it has been halted.

According to [MSDN]:

Stop Debugging terminates the process you are debugging if the program was launched from Visual Studio.

However you may be able to achieve what you want with a visual studio add-in.

这篇关于停止调试事件在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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