ActiveX控件无法实例,因为当前线程不是在一个单一的线程单元 [英] ActiveX control cannot be instantiated because the current thread is not in a single-threaded apartment
问题描述
由于对象是自explainatory,我需要帮助。
As the subject is self explainatory, I need help.
我正在写一个小工具,启动时显示一个闪屏。 启动画面是一个形式。当只有一个按钮控件上它是工作的罚款。 但是,当我删除它,放在一个WebBrowser控件就可以了,它抛出上述异常。
I'm writing a small tool that displays a splash screen when starting. The splash screen is a Form. When there was only a Button control on it it was working fine. But when I removed it and placed a WebBrowser control on it, it throws the above exception.
在此先感谢。
推荐答案
您使用的WinForms?如果是这样,请尝试将[STAThread]属性的类定义的顶部,看看会发生什么:
Are you using WinForms? If so, try placing the [STAThread] attribute at the top of your class definition and see what happens:
命名空间WindowsFormsApplication1 { [STAThread] 公共部分类Form1中:形态 {
namespace WindowsFormsApplication1 { [STAThread] public partial class Form1 : Form {
这篇关于ActiveX控件无法实例,因为当前线程不是在一个单一的线程单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!