在Windows Forms应用程序中使用Console.WriteLine [英] Using Console.WriteLine within a Windows Forms application

查看:305
本文介绍了在Windows Forms应用程序中使用Console.WriteLine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个外部DLL,其源代码为C#.从DLL的文档中,我确定它使用Console.WriteLine将调试消息写入控制台.

I have an external DLL whose source code is C#. From the documentation for the DLL, I determined that it writes its debug messages to the console using Console.WriteLine.

我想在WinForms应用程序中使用此DLL.但是,我发现由于WinForms应用程序没有控制台,所以我看不到DLL发出的调试消息.

I'd like to use this DLL within a WinForms application. However, what I have discovered is that I cannot see the debug messages emitted by the DLL since a WinForms application does not have a console.

是否有一种方法可以捕获那些调试消息,甚至可以捕获到简单的日志文件中?当然,使用ProcessInfo.RedirectStandartOutput将不起作用,因为我没有将DLL用作进程.

is there a way to capture those debug messages, perhaps even to a simple log file? Of course, using ProcessInfo.RedirectStandartOutput will not work as I do not use the DLL as a process.

推荐答案

致电

Call Console.SetOut with a TextWriter you control (e.g. a StringWriter).

这篇关于在Windows Forms应用程序中使用Console.WriteLine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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