Console.Write Not Working In Win Forms App

前端 未结 7 1210
走了就别回头了
走了就别回头了 2021-01-12 05:08

I created a VB.NET Windows Forms Application in Visual Studio 2008. When I run my program from the command-line, I get no output (only the next prompt).

What am I d

7条回答
  •  星月不相逢
    2021-01-12 05:32

    Or if you already have a WinForms application you can attach a Console to it using the AttachConsole API.

    using System.Runtime.InteropServices;  
    

    ...

    [DllImport("kernel32.dll")] static extern bool AttachConsole(int dwProcessId);
    private const int ATTACH_PARENT_PROCESS = -1;  
    

    ...

    AttachConsole(ATTACH_PARENT_PROCESS);
    

    (Formatted as code)

提交回复
热议问题