4

My installer needs to open a file browse dialog. As there is no file browse dialog provided by WIX I have written a C# dll containing a method to invoke the standard OpenFileDialog when called by a Custom Action. However while this works fine in Win2003 the Custom Action just hangs when run on Windows 7. It seems to get as far as the ShowDialog() call then stop. As a test I have written a separate Windows Forms app with a single dialog and button to invoke the OpenFileDialog and, as expected, that works fine. I just can't get the OpenFileDialog to appear from within my msi!

I suspect it may be a security thing so I ran the installer from msiexec opened as Administrator but with no difference!

Does anyone have any ideas how to fix this?

Many Thanks.

4

2 回答 2

2
  // create a new thread with appropriate apartment state to launch UI 
  OpenFileDialog fileBrowser = new OpenFileDialog(); 
  Thread worker = new Thread(fileBrowser.Show); 
  worker.SetApartmentState(ApartmentState.STA);  // <-- here is the magic code 
  worker.Start(); 
  worker.Join(); 
于 2011-07-13T13:05:32.463 回答
0

当我尝试这样做时,我发现它在其他 MSI 窗口后面弹出。在我弄清楚这一点之前,它看起来就像一个挂起。

由于这个以及其他一大堆原因,我最终编写了一个定制的安装机制并放弃了 MSI。最终对用户和他们的系统更加友好。

于 2010-09-16T16:25:48.737 回答