添加到 System.Diagnostics.Debug.Listeners 时 TextWriterTraceListener 未按预期工作
完整程序:
Option Strict On : Option Explicit On Module Module1
Sub Main()
'System.Diagnostics.Debug.Listeners.Add(New System.Diagnostics.TextWriterTraceListener("C:\a.txt"))
System.Diagnostics.Debug.Listeners.Add(New System.Diagnostics.TextWriterTraceListener("a.txt"))
System.Diagnostics.Debug.WriteLine("asd")
End Sub
End Module
运行后,我的调试文件夹中有一个文件 a.txt,但大小为 0 字节(当然,当我打开它时它是空的)
输出中不应该有“asd”吗?
Full Program:
Option Strict On : Option Explicit On Module Module1
Sub Main()
'System.Diagnostics.Debug.Listeners.Add(New System.Diagnostics.TextWriterTraceListener("C:\a.txt"))
System.Diagnostics.Debug.Listeners.Add(New System.Diagnostics.TextWriterTraceListener("a.txt"))
System.Diagnostics.Debug.WriteLine("asd")
End Sub
End Module
After I ran it, I had a file a.txt in my debug folder but the size is 0 bytes (and when i open it is empty of course)
Shouldn't the output had "asd" in it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加一个或多个
语句,和/或
关闭该应用程序时的语句。
Add one or more
statements, and/or a
when closing that App.
这个问题我也很久以前就发现了。如果您愿意使用 CriticalFinalizer,则每次都可以周围进行刷新。
I have found this issue also a long time ago. You can get around flushing every time if you are willing to use a CriticalFinalizer.