Current thread must be set to single thread apartment (STA) mode before OLE,当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“8856f961-340a-11d0-a96b-00c04fd705a2”。
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
Current thread must be set to single thread apartment (STA) mode before OLE,当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“8856f961-340a-11d0-a96b-00c04fd705a2”。的更多相关文章
- C# Current thread must be set to single thread apartment (STA) mode before OLE calls can be made
将箭头指向部分替换为编译器报错的内容即可. 参考文章:https://www.experts-exchange.com/questions/28238490/C-help-needed-Current ...
- 多线程系列之二:Single Thread Execution 模式
一,什么是SingleThreadExecution模式?同一时间内只能让一个线程执行处理 二,例子 1.不安全的情况 用程序模拟 三个人频繁地通过一个只允许一个人经过的门.当人通过时,统计人数便会增 ...
- How does a single thread handle asynchronous code in JavaScript?
原文:https://www.quora.com/How-does-a-single-thread-handle-asynchronous-code-in-JavaScript ----------- ...
- Single Thread Execution 能通过这座桥的只有一个人
直奔主题, Single Thread Execution也称作Critical Section(临界区),范例如下: public class SingleThreadGate { public s ...
- 扩展BindingList,防止增加、删除项时自动更新界面而不出现“跨线程操作界面控件 corss thread operation”异常
在做界面程序时,常常需要一些数据类,界面元素通过绑定等方式显示出数据,然而由于UI线程不是线程安全的,一般都需要通过Invoke等方式来调用界面控件.但对于数据绑定bindingList而言,没法响应 ...
- 14.4.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB Master Thread I/O Rate
14.4.8 Configuring the InnoDB Master Thread IO Rate 配置InnoDB Master Thread I/O Rate 主的master thread ...
- WinFrom Thread里面new出来的控件不显示
那本More Effective C# 好多天没看了..惭愧. 做个小笔记吧. 今天碰到一个问题,描述如题. 何解?其实很简单,因为Thread里面new出来的控件的Parent是null,然后他就不 ...
- 002-线程实现方式【thread、runnable、callale、thread和runnable对比】
一.概述 1.实现方式 在java中对于多线程实现一定要有一个线程的主类,而这个线程的主类往往是需要操作一些资源,但是对于多线程主类的实现是: 继承Thread父类 从java的Thread类继承实现 ...
- Thread类的sleep()方法和对象的wait()方法都可以让线程暂停执行,它们有什么区别? 线程的sleep()方法和yield()方法有什么区别?
Thread类的sleep()方法和对象的wait()方法都可以让线程暂停执行,它们有什么区别? sleep()方法(休眠)是线程类(Thread)的静态方法,调用此方法会让当前线程暂停执行指定的时间 ...
随机推荐
- IOS集成到支付宝的步骤及问题
一,在支付宝开放平台下载支付宝SDK(https://openhome.alipay.com/platform/document.htm#down) 二,添加sdk文件到xcode 1,新建一个ali ...
- Windows 10新增的6个快捷键:
Win+方向箭头:调整窗口贴边位置 Alt+Tab:切换窗口,按住不松时会有一个全新的界面方便你在不同的窗口间选择 Win+Tab:切换任务,这个松开后界面不会消失 Win+Ctrl+D:创建新的虚拟 ...
- C#开源框架整理
Json.NET http://json.codeplex.com/ Json.Net 是一个读写Json效率比较高的.Net框架.Json.Net 使得在.Net环境下使用Json更加简单.通过Li ...
- ELK集群模式部署
架构拓扑图为: 准备工作: 下载资源包: Elasticsearch: wget https://artifacts.elastic.co/downloads/elasticsearch/elasti ...
- LaTeX:Figures, Tables, and Equations 插入图表和公式
Figures To insert a figure in a LaTeX document, you write lines like this: \begin{figure} \centering ...
- humanoid ik unity 配件 animation的问题
遇到这样一个问题 想给角色设置ik 以实现代码控制的 更为自然的 角色动作 比如角色头跟随点击转动 身体也有相应扭转 https://docs.unity3d.com/Manual/InverseKi ...
- Hibernate异常:Unable to locate appropriate constructor on class
异常信息:org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class o ...
- centos6.8服务器配置之编译安装PHP、配置nginx
php version 5.6.31.nginx version: nginx/1.10.2 1.下载: wget http://cn2.php.net/distributions/php-5.6.3 ...
- 不输入sudo使用docker
系统是debian系 安装: sudo apt install docker.io 将当前用户加入‘docker’组: sudo gpasswd -a ${USER} docker 刷新权限: su ...
- VP9 Video Codec
http://www.webmproject.org/vp9/ WebM Repositories libvpx: VP8/VP9 Codec SDK pull http://git.chromi ...