Место общения программистов C#
Anonymous
Debug.WriteLine() ничего не выводит – VS Code на Mac
Сообщение
Anonymous » 30 апр 2024, 18:55
Я использую VS Code на Mac. У меня есть проект .NET Maui, и я хочу получить выходные данные с помощью Debug.WriteLine().
Несколько вещей:
#if DEBUG работает правильно
Console.WriteLine() успешно выводит данные на терминал (но по какой-то причине записывает дважды)
Debugger.IsAttached выводит True
Trace.WriteLine() тоже НЕ работает
По какой-то причине Console.WriteLine() работает, но записывает все дважды, и я не знаю почему.
Код: Выделить всё
namespace MauiApp;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp()
.UseSkiaSharp()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("SF-Pro.ttf", "SF-Pro");
fonts.AddFont("Font Awesome 6 Duotone-Solid-900.otf", "Font Awesome 6 Duotone");
fonts.AddFont("Font Awesome 6 Pro-Regular-400.otf", "Font Awesome 6 Regular");
fonts.AddFont("Font Awesome 6 Pro-Light-300.otf", "Font Awesome 6 Light");
}).ConfigureEssentials(essentials =>
{
essentials.UseVersionTracking();
});
#if DEBUG
// builder.Logging.AddDebug();
builder.Services.AddLogging(configure => {
configure.AddDebug();
});
Console.WriteLine("--- is debugger attached -------------------------------------");
Console.WriteLine(Debugger.IsAttached);
Console.WriteLine("----------------------------------------");
Debug.WriteLine("This is a debug write line test.");
Trace.WriteLine("This is a trace write line test.");
#endif
return builder.Build();
}
}
Мой код
Вывод терминала
Подробнее здесь:
https://stackoverflow.com/questions/784 ... ode-on-mac
1714492544
Anonymous
Я использую VS Code на Mac. У меня есть проект .NET Maui, и я хочу получить выходные данные с помощью Debug.WriteLine(). Несколько вещей: [list] [*]#if DEBUG работает правильно [*]Console.WriteLine() успешно выводит данные на терминал (но по какой-то причине записывает дважды) [*]Debugger.IsAttached выводит True [*]Trace.WriteLine() тоже НЕ работает [/list] По какой-то причине Console.WriteLine() работает, но записывает все дважды, и я не знаю почему. [code]namespace MauiApp; public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .UseSkiaSharp() .UseMauiCommunityToolkit() .ConfigureFonts(fonts => { fonts.AddFont("SF-Pro.ttf", "SF-Pro"); fonts.AddFont("Font Awesome 6 Duotone-Solid-900.otf", "Font Awesome 6 Duotone"); fonts.AddFont("Font Awesome 6 Pro-Regular-400.otf", "Font Awesome 6 Regular"); fonts.AddFont("Font Awesome 6 Pro-Light-300.otf", "Font Awesome 6 Light"); }).ConfigureEssentials(essentials => { essentials.UseVersionTracking(); }); #if DEBUG // builder.Logging.AddDebug(); builder.Services.AddLogging(configure => { configure.AddDebug(); }); Console.WriteLine("--- is debugger attached -------------------------------------"); Console.WriteLine(Debugger.IsAttached); Console.WriteLine("----------------------------------------"); Debug.WriteLine("This is a debug write line test."); Trace.WriteLine("This is a trace write line test."); #endif return builder.Build(); } } [/code] [b]Мой код[/b] [img]https://i.sstatic.net/EDEbU6cZ.png[/img] [b]Вывод терминала[/b] [img]https://i.sstatic.net/LyMfpOdr.png[/img] Подробнее здесь: [url]https://stackoverflow.com/questions/78409522/debug-writeline-is-not-outputting-anything-vs-code-on-mac[/url]