Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF C#4.0
Hi to all,
      I want to open SaveFileDialog Box. But am getting the Error :
 
      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.
 
   I am Developing the project using WPF and VS2010. Developed UI Using WPF. At the manager Layer I tried to Open SaveFileDialog Box.
   I tried To set the [STAThreadAttribute] and [STAThread] attributes but I was not able to implement that   can any one help me please.
Posted 5-Oct-10 20:17pm
Edited 5-Oct-10 21:19pm
v2
Comments
Khaniya at 9-Oct-10 2:57am
   
where you have set [STAThreadAttribute] and [STAThread]
?????

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I hav face the same probleme , to call a COM object
 
what i did , is make a thread with single thread apartment ,
 
and do what i have to do
Thread staThread = new Thread(new ThreadStart (myMethod));
staThread.ApartmentState = ApartmentState.STA;
staThread.Start();
 
public static void myMethod()
{
    //Call COM Object
}
  Permalink  
Comments
Dalek Dave at 13-Oct-10 5:53am
   
Good Call

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



Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 13 Oct 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100