Add the STAThreadAttribute attribute on the Main method. This attribute is required if your program access OLE related functions, like Clipboard class does.
C#
[STAThread]
static void Main(string[] args)
{
}
Visual Basic
<STAThread()> _
Shared Sub Main(args As String())
End Sub
或者
Thread t = new Thread(ThreadProc); Console.WriteLine("Before setting apartment state: {0}", t.GetApartmentState()); t.SetApartmentState(ApartmentState.STA); Console.WriteLine("After setting apartment state: {0}",
參考
Tread.SetApartmentState 方法 (ApartmentState)
https://msdn.microsoft.com/zh-tw/library/system.threading.thread.setapartmentstate(v=vs.110).aspx
全站熱搜
留言列表