C#调试日志控制台应用程序 [英] C# debug log console app
问题描述
我正在尝试创建一个控制台窗口以使用C#进行调试.
I am trying to create a console window for debugging in C#.
例如,请考虑以下情形:
我有一个表单应用程序,我想将事件实时记录到控制台窗口.
触发事件后,表单应用程序应将要打印的数据发送到控制台应用程序,以便我可以看到事件何时被触发以及有关特定事件的数据.
当我在控制台应用程序中输入特定命令时,它将命令发送到表单应用程序并触发事件.
For example, consider the following scenario:
I have a forms app and I want to log events to a console window in real time.
When an event is triggered the forms app should send data to be printed to the console app so that I can see when the event is triggered and data about the specific event.
When I input a specific command in the console app, it sends the command to the forms app and triggers the event.
因为它是用于调试的,所以控制台应该是一个单独的应用程序,这样,如果主应用程序死了,控制台窗口就不会.
Because it is for debugging, the console should be a separate app so that if the main app dies, the console window won't.
如果我做对了,我认为我应该能够使Console应用程序与诸如Console2/Conemu之类的程序一起工作.
If I do this right I assume I should be able to get the console app working with programs such as Console2/Conemu.
有人知道实现这一目标的正确方法吗?
Does anyone know the correct technique to achieve this?
推荐答案
这些方法取决于您要如何初始化进程之间的通信.我相信,命名管道-是最佳选择.但是,如您所愿...
Thee ways, I think, depending how do you want to initialize communication between your processes. I believe, named pipes - is the best choice. But as you wish...
1)您可以使用以下命令创建"控制台
1) You may "create" your console with following command
ConEmuC.exe /ATTACH /ROOT "<Full path to your console\part.exe>" <Arguments console part>
or
ConEmu.exe /cmd "<Full path to your console\part.exe>" <Arguments console part>
2)附加"是从通常启动的控制台部件应用程序创建的控制台.阅读此处.这个想法是在刚刚创建的免费控制台中运行以下命令.
2) "Attach" created console from normally started console part application. Read here. The idea is to run following command in the free, just created console.
ConEmuC.exe /AUTOATTACH
3)最后,您可以尝试使用默认终端"功能.在此处中进行描述.
3) At last, you may try "Default Terminal" feature. Described here.
这篇关于C#调试日志控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!