It is perfectly possible to use WinForms from a Console application. You just need to add a Reference to System.Windows.Forms. Thereafter, you can add any code that uses WinForms. The only pitfall is that you need add the [STAThread] attribute to your Main method. Otherwise, the OpenFileDialog instantiation will block/deadlock when running on Microsoft .net framework. On Mono, everything runs fine without the [STAThread] attribute, but to eliminate portability issues, you probably want to add it.
[STAThread]public static void Main (string[] args){ OpenFileDialog openDialog = new OpenFileDialog (); openDialog.ShowDialog ();}
Nenhum comentário:
Postar um comentário