本文介绍了MonoDevelop中的调试/跟踪输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里可以看到MonoDevelop中的System.Diagnostics.Debug和System.Diagnostics.Trace输出?我认为它应该出现在ApplicationOutput窗口中,但无处可寻.

Where can I see System.Diagnostics.Debug and System.Diagnostics.Trace output in MonoDevelop? I would think it should appear in the ApplicationOutput window, but it's nowhere to be found.

推荐答案

应用程序输出"窗口将显示Console.WriteLine的结果.

The Application Output window will show the results of Console.WriteLine.

如果您希望Windows和Mono上都可以使用Visual Studio,请在Program.cs文件中添加如下所示的静态方法:

If you want something that works with Visual Studio on Windows as well as on Mono, then add a static method like the following to your Program.cs file:

    public static void WriteLine(String fmt, params Object[] args)
    {
        string op;
        if (fmt == null)
            op = String.Empty;
        else if (args == null || args.Length == 0)
            op = fmt;
        else
            op = String.Format(fmt, args);
        Trace.WriteLine(op);
        DateTime now = DateTime.Now;
        string outString = String.Format("{0,4}-{1,2:0#}-{2,2:0#} {3,2:0#}:{4,2:0#}:{5,2:0#} : {6}",
            now.Year, now.Month, now.Day,
            now.Hour, now.Minute, now.Second,
            op);
        Console.WriteLine(outString);
    }

这篇关于MonoDevelop中的调试/跟踪输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 23:52