Before you can call OLE, you must set the current thread to single-threaded apartment (STA) mode, and make sure that your main function has a stathreadattribute tag. Multi-threaded operation when cutting the plate.

Source: Internet
Author: User
Tags ole

The most recent thing that hurts is that C # calls the Windows API to manipulate a software that automatically handles something. To use the Clipboard copy and paste function, i.e. Clipboard.setdataobject (Filedic, true), etc.

Originally tested, the main thread button clicked to start without any problems. But putting the whole process on a single thread is an error when it's copied,

"Before you can call OLE, you must set the current thread to single-threaded apartment (STA) mode, make sure your main function has a stathreadattribute tag." But look at my main thread next to the win tag on the main function.

Do not know how to do, think is not to be on the thread function is also marked, but I think too much, no. Final Niang Search Multithreading "before you can call OLE, you must set the current thread to single-threaded apartment (STA) mode, and make sure your main function has a stathreadattribute tag"

Error, Degree Niang know thread has a apartmentstate attribute, in fact, I did not understand, I know that there is an STA enumeration type. Think about the problem here. The individual thread is set to _thread. Setapartmentstate (ApartmentState.STA);

There was no such error. Sort of solved the problem. But why is that. And so on later study understood to update the essay.

Before you can call OLE, you must set the current thread to single-threaded apartment (STA) mode, and make sure that your main function has a stathreadattribute tag. Multi-threaded operation when cutting the plate.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.