static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (StreamWriter writer = new StreamWriter("console.txt")) { Console.SetOut(writer); ViewerForm viewerForm = new ViewerForm(); try { viewerForm.setWindowParametersFromCommandLineArguments(args); Application.Run(viewerForm); } catch (Exception e) { Console.WriteLine("Got Exception running render thread: {0} exiting", e); Application.Exit(); } } }