如果我将System.Diagnostics.Debug.WriteLine放在Global.asax.cs中,输出会去哪里?
如果我将System.Diagnostics.Debug.WriteLine放在Global.asax.cs中,输出会去哪里?
以下的C#程序(使用csc hello.cs
编译)仅在控制台上打印Hello via Console!
,并在DebugView窗口中打印Hello via OutputDebugString
。然而,我无法看到System.Diagnostics.*
调用。为什么会这样呢?
using System; using System.Runtime.InteropServices; class Hello { [DllImport("kernel32.dll", CharSet=CharSet.Auto)] public static extern void OutputDebugString(string message); static void Main() { Console.Write( "Hello via Console!" ); System.Diagnostics.Debug.Write( "Hello via Debug!" ); System.Diagnostics.Trace.Write( "Hello via Trace!" ); OutputDebugString( "Hello via OutputDebugString" ); } }
也许在csc
中需要一些特殊的命令行开关吗?
我没有使用Visual Studio进行任何开发,这是纯命令行操作。
admin 更改状态以发布 2023年5月24日