停止调试事件在C#事件

由网友(花臂暖男@)分享简介:如何或在哪里可以运行一个命令,在应用程序关闭时,即使是调试停止了吗?我需要在任何退出执行命令,即使用户是开发者和点击停止调试按钮,在Visual Studio中。我有尝试Application.ApplicationExit + =新的EventHandler(this.OnApplicationExit);,但它不工...

如何或在哪里可以运行一个命令,在应用程序关闭时,即使是调试停止了吗?

我需要在任何退出执行命令,即使用户是开发者和点击停止调试按钮,在Visual Studio中。

我有尝试

  Application.ApplicationExit + =新的EventHandler(this.OnApplicationExit);
 

,但它不工作。也许我是错的,或者不是事件。

我使用的WinForms,而不是,表格关闭不可能事件。

我在使用Visual Studio 2005 .Net框架2.0(按客户要求),但仅仅是信息。

也许我也可以重写此:

 公共静态无效退出();
 

解决方案

现在的问题是停止调试功能将停止应用程序完全 - 这样不再 $ C $该应用程序中按c运行。

CodeBlocks调试简要教程

您只能实现,这将是观看正在调试的进程外,执行code,如果它已经停止的方式。

根据 MSDN :

  

停止调试结束,如果该程序正在调试的过程   从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.

阅读全文

相关推荐

最新文章