无法通过控制台应用程序的反射启动时创建窗口 [英] Failed to create a window when launching it through reflection from the console app

查看:194
本文介绍了无法通过控制台应用程序的反射启动时创建窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过从窗体表单程序集调用几个方法来启动一个对话框。我的应用程序是一个控制台应用程序。所有的执行逻辑运行良好,没有异常,但窗口不启动。这是一个已知的问题,你不能从控制台应用程序启动Windows窗体?

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?

推荐答案

很好,是的。您必须有一个Windows消息循环才能正常工作。
如果从头开始创建一个Forms应用程序,你会看到用 ... Application.Run(new YourMainForm())创建的Program.cs模块它。运行基本上是消息泵 - 这几乎是表单工作的要求。

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.

这篇关于无法通过控制台应用程序的反射启动时创建窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆