In your custom action, create and start a new thread and then wait on it. In
that new thread, initialize COM for STA mode (or just initialize OLE, which
will do that for you) and then call the OpenFileDialog class. After you copy
your file path out of the class, let that thread end, which will release the
thread your custom action entered on, and set your property with the path
you received from the user.

-----Original Message-----
From: Elfe Xu [mailto:elf...@microsoft.com] 
Sent: Thursday, June 24, 2010 12:57 PM
To: wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] No OpenFileDialog or something like that?


@Johannes
Thanks for the link to wixwiki. But these samples are too simple and do not
show the complex usage for me to refer :(

I tried to write a custom action to use OpenFileDialog class. However, the
CA gets exceptions "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 found an old post
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Detecting-IA64
-bit-architecture-td1381532.html#a1383764
here  say that I need to create a new thread to invoke the function. Since
it is a old post (2008) and Joson had suggest to submit a feature requrest
for this requirement, I would like to know if there is any easy way to
achieve this now.
-- 
View this message in context:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/No-OpenFileDia
log-or-something-like-that-tp5216565p5219318.html
Sent from the wix-users mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to