Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Additional information: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
Posted
Updated 18-Aug-15 22:02pm
v2
Comments
Patrice T 19-Aug-15 3:48am    
If this is Additional infirmationfor another Question, use "Improve question" instead.
Because this question have not meaning by itself.
Member 11889312 19-Aug-15 4:02am    
is it ok
Richard MacCutchan 19-Aug-15 4:14am    
Do what the message tells you.
Sanket Saxena 19-Aug-15 5:16am    
Additional information itself explain the problem and the solution.
Philippe Mori 19-Aug-15 12:47pm    
The error message already explain the problem and even tell how to fix it!

If you get an error message you don;t understand, start by passing it to Google: Google "Current thread must be set to ... is attached to the process"[^]
It's very likely that whatever message you have, has been met, explained, and fixed many times before - as is the case here.

Follow some of the links and see what they say. Or in this case, do exactly what the error message tells you to do, and apply the STAThreadAttribute to your Main function:
C#
static class Program
    {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
        {
        ...
        }
    }
 
Share this answer
 
thank you it works........................................................................................................................
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900