You can attach the console. Make the code in Program.cs as follows:
[STAThread] static void Main(string[] args) { if (args.Length > 0) { AttachConsole(-1); Console.WriteLine(""); Console.WriteLine("Running in console, press ENTER to continue"); Console.ReadLine(); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } [System.Runtime.InteropServices.DllImport("kernel32.dll")] private static extern bool AttachConsole(int pid);
Hans passant
source share