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
此随笔或为自己所写、或为转载于网络。仅用于个人收集及备忘。