Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32062

WPF window build dll COM VBA

$
0
0
Hello,
I wrote a little COM-visible dll which can show a WPF window. I set my dll in a VBA script reference (excel -> VBA) and when I run first time everything is OK, after that the VBA sub is finished and I try to run this script again and I get an error message:

"Cannot create more than one System.Windows.Application instance in the same AppDomain."

the relevant part of code:
classProgram1{privatevoidShowWindow(){_MainWindow=newMainWindow();Application app =newApplication();
            app.Run(_MainWindow);
            app.Shutdown();}publicvoidStartWindow(){
            appthread =newThread(ShowWindow);
            appthread.Name="wth";
            appthread.SetApartmentState(ApartmentState.STA);
            appthread.IsBackground=true;
            appthread.Start();}}


Viewing all articles
Browse latest Browse all 32062

Trending Articles