Failed to create a window when launching it throug

2019-08-29 02:06发布

问题:

Im trying to launch a dialog by invoking several methods from a windows forms assembly. My app is a console app. All the execution logic goes well and without exceptions, but the window is not launched. Is it a known issue that you cant launch a windows form from a console app?

回答1:

well, yes. You have to have a Windows message loop for this to work. If you create a Forms application from scratch, you'll see the Program.cs module created with ... Application.Run(new YourMainForm()) in it. Run is basically the message pump - having that is pretty much a requirement for forms to work.