【发布时间】: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