【问题标题】:Debug.WriteLine("Hello World!") - Does not appear in the outputDebug.WriteLine("Hello World!") - 不出现在输出中
【发布时间】:2021-06-11 09:29:54
【问题描述】:

问题

我正在开发一个 UWP通用 Windows 平台)应用程序,作为测试,我包含了

Debug.WriteLine("Hello World!"); 方法,但是在输出中没有显示在方法中输入的文本

问题

该方法是否被我错误地集成到 UWP 应用程序中?

源代码

using System;
using System.Diagnostics;
using Windows.System;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml.Controls;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace UwpApplication1
{
    /// <summary>
    ///     An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            
            Debug.WriteLine("Hello World! - Debug.Writeline() Test");

        }
    }
}

【问题讨论】:

  • “输出”具体是什么意思?您是否正在查看 Visual Studio 的输出窗口,并在“显示输出自:”中选择了调试?
  • 您好,我使用的是 Jetbrains Rider IDE,输出是指控制台输出。
  • 是的,UWP 应用程序内置在 Debug | x64 模式。
  • Debug.WriteLine 默认情况下不会写入控制台,它会写入默认跟踪侦听器。我会想象 Rider 有一个像视觉工作室这样的输出查看器。否则,您可以添加一个跟踪侦听器,您可以阅读文档中的 System.Diagnostics.Debug。或者只是使用 Console.WriteLine
  • 感谢您的信息!我会做这个研究! :)

标签: c# debugging methods uwp winui-3


【解决方案1】:

如果您希望在 Visual Studio 输出而不是 UWP 应用程序中显示“Hello, World”,您只需编写 Console.WriteLine() 而不是 Debug.WriteLine()

如果您希望它显示在 UWP 应用程序中,您可以创建一个文本块(无代码)。在调试中编写“Hello, World!”只会在输出中显示一条评论,用户在实际应用中看不到

如果您想要控制台输出,只需输入Console.WriteLine()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-24
    • 2010-10-07
    • 1970-01-01
    • 2011-06-01
    • 2018-08-13
    • 1970-01-01
    相关资源
    最近更新 更多