2003-03-16

STA Threads in HREF EXE's

"Tonight I converted them all to HREF EXEs. I had a little snag, it turns out that when IEExec hosts your EXE it doesn't run it in the same type of Apartment as when you execute it directly (which doesn't matter for most things, but it screws up COM automation and drag and drop), but just adding

System.Threading.Thread.CurrentThread.ApartmentState = Threading.ApartmentState.STA

to the start of my app fixed that right up. (and, no, just adding the STA attribute wouldn't do it... in case you are wondering)"

[Code/Tea/Etc...]

That's a hot tip! I just recently had a problem with this. I was running an HREF EXE hosting a webbrowser control and got an error because it wasn't running in a STA. I thought just by adding [STAThread] would do it but apparently not.

0 Comments:

Post a Comment

<< Home