Current thread must be set to single thread apartment (STA) mode before OLE,当前线程不在单线程单元中,因此无法实例化 Act...

设置STA线程属性
本文介绍了如何通过在Main方法上添加STAThreadAttribute属性来确保程序能够正确访问OLE相关的功能,例如使用Clipboard类。同时提供了两种创建具有STA公寓状态的线程的方法。
Add the STAThreadAttribute attribute on the Main method. This attribute is required if your program access OLE related functions, like Clipboard class does.

[STAThread]
static void Main(string[] args)
{
}

  

使用以下方式
var t = new Thread(MyThreadStartMethod);
t.SetApartmentState(ApartmentState.STA);
t.Start();
或者

th = new System.Threading.Thread(new System.Threading.ThreadStart(
() =>
{
Start.Run();
}));

th.SetApartmentState(ApartmentState.STA);
th.Start();
能解决

  参考;http://blog.sina.com.cn/s/blog_891b90e90101c4vq.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值