views:

74

answers:

1

Greetings all,

I have a question. I have created a WPF application. So, I naturally created an installer (Visual Studio Install project) for it.

In the Commit section of the installer I want to launch a WPF window which is my configuration wizard.

So I created a Installer class, overrode the Commit method and put the following in method: Application theApp = new Application;
theApp.Run (new MyWPFWizardWindow());

I keep getting the error:
The calling thread must be STA, because many UI components require this.

No problems, this makes as it is a GUI application. But I can't, for the life of me, get the installer to fire up my window. I have tried putting [STAThread] on the method. I have tried firing up a thread and setting the ApartmentState to STA. I am guessing it's something really simple that I am over looking. Anyone have any thoughts?

Thanks in advance..

cmb..

+1  A: 

Setting AppartmentState to STA before starting a thread should do the trick...

Try doing that, but instead of

new Application().Run(new MyWPFWizardWindow());

do

new MyWPFWizardWindow().ShowDialog();

... which is pretty similar, but doesn't create an instance of Application class (which you can't have more than one).

repka
That seemed to work. I can show my window now. Am running into other issues, but this solved that one issue.
cbeuker