简体   繁体   English

AppDomain.CurrentDomain.UnhandledException不允许我完成功能

[英]AppDomain.CurrentDomain.UnhandledException does not let me finish my function

Currently, I have a method that is called when there is an unhandled exception. 当前,我有一个未处理的异常时调用的方法。 All this does is log the exception to a dump file. 这一切都是将异常记录到转储文件中。 However, the streamwriter does not write the full information I'd like it to write to the file. 但是,streamwriter不会将我希望其写入的完整信息写入文件。 I assume this is because the program has shutdown before it can finish writing the file. 我认为这是因为程序在完成写入文件之前已关闭。

Is there any way to change this behaviour? 有什么办法可以改变这种行为?

在流Flush上调用Flush

use 采用

using(var stream = new StreamWriter(@"C:\..."))
{
    //logic
}

This will make sure, that stream will be closed and flushed in the finally section. 这将确保在finally部分中将关闭并刷新该流。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不会调用AppDomain.CurrentDomain.UnhandledException - AppDomain.CurrentDomain.UnhandledException does not get called AppDomain.CurrentDomain.UnhandledException不起作用 - AppDomain.CurrentDomain.UnhandledException Not working 处理AppDomain.CurrentDomain.UnhandledException中的异常 - Handle exceptions in AppDomain.CurrentDomain.UnhandledException Revit Addin中的AppDomain.CurrentDomain.UnhandledException - AppDomain.CurrentDomain.UnhandledException in Revit Addin 在Windows服务中处理AppDomain.CurrentDomain.UnhandledException - Handling AppDomain.CurrentDomain.UnhandledException in windows service 为什么我的AppDomain.CurrentDomain.UnhandledException事件始终不触发? - Why doesn't my AppDomain.CurrentDomain.UnhandledException event always fire? Application.ThreadException 和 AppDomain.CurrentDomain.UnhandledException 都不受尊重 - Neither Application.ThreadException nor AppDomain.CurrentDomain.UnhandledException are respected 我可以在 class 库中向 AppDomain.CurrentDomain.UnhandledException 添加处理程序吗 - Can I Add a handler to AppDomain.CurrentDomain.UnhandledException in a class library 抑制 Application.ThreadException 和 AppDomain.CurrentDomain.UnhandledException - Suppressing Application.ThreadException and AppDomain.CurrentDomain.UnhandledException 处理AppDomain.CurrentDomain.UnhandledException时是否无法显示表单? - Is it impossible to show forms when handling a AppDomain.CurrentDomain.UnhandledException?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM