Click here to Skip to main content
Rate this: bad
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 21:17pm
Edited 5-Oct-10 22:19pm
Khaniya at 9-Oct-10 2:57am
where you have set [STAThreadAttribute] and [STAThread]

1 solution

Rate this: bad
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;
public static void myMethod()
    //Call COM Object
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.150327.1 | Last Updated 13 Oct 2010
Copyright © CodeProject, 1999-2015
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