The calling thread must be STA, because many UI components require this The calling thread must be STA, because many UI components require this wpf wpf

The calling thread must be STA, because many UI components require this


Try to invoke your code from the dispatcher:

Application.Current.Dispatcher.Invoke((Action)delegate{      // your code});


If you make the call from the main thread, you must add the STAThread attribute to the Main method, as stated in the previous answer.

If you use a separate thread, it needs to be in a STA (single-threaded apartment), which is not the case for background worker threads. You have to create the thread yourself, like this:

Thread t = new Thread(ThreadProc);t.SetApartmentState(ApartmentState.STA);t.Start();

with ThreadProc being a delegate of type ThreadStart.


You can also try this

// create a thread  Thread newWindowThread = new Thread(new ThreadStart(() =>  {      // create and show the window    FaxImageLoad obj = new FaxImageLoad(destination);      obj.Show();          // start the Dispatcher processing      System.Windows.Threading.Dispatcher.Run();  }));  // set the apartment state  newWindowThread.SetApartmentState(ApartmentState.STA);  // make the thread a background thread  newWindowThread.IsBackground = true;  // start the thread  newWindowThread.Start();