穿线错误 [英] threading error

查看:54
本文介绍了穿线错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于当前线程不在单线程单元中,因此无法实例化ActiveX控件"d27cdb6e-ae6d-11cf-96b8-444553540000".

我该怎么解决
我单击表单1按钮时要添加两个表单,我要在form2中打开form2,我在运行Form2时添加了axShockwaveFlash1,此时我遇到此错误

ActiveX control ''d27cdb6e-ae6d-11cf-96b8-444553540000'' cannot be instantiated because the current thread is not in a single-threaded apartment.

how can i solve this
i add two forms when i click the form 1 button i want open the form2 in form2 i added axShockwaveFlash1 when i run the form2 that time i am getting the this error

推荐答案

您遇到的问题是,大多数后台线程/辅助API会在多线程单元"状态下创建线程.错误消息表明控件要求线程是单线程单元.

您可以通过自己创建一个线程并在该线程上指定STA单元状态来解决此问题.

通过此链接:
http://stackoverflow.com/questions/1418466/single-threaded-apartment-无法实例化activex-control [ ^ ]

The problem you''re running into is that most background thread / worker APIs will create the thread in a Multithreaded Apartment state. The error message indicates that the control requires the thread be a Single Threaded Apartment.

You can work around this by creating a thread yourself and specifying the STA apartment state on the thread.

From this link:
http://stackoverflow.com/questions/1418466/single-threaded-apartment-cannot-instantiate-activex-control[^]

var t = new Thread(MyThreadStartMethod);
t.SetApartmentState(ApartmentState.MTA);
t.Start();



祝你好运!



Good luck!


这篇关于穿线错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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