OpenFileDialog 在 Win7 上失败

发布于 2024-09-19 22:49:18 字数 380 浏览 4 评论 0原文

我的安装程序需要打开一个文件浏览对话框。由于 WIX 没有提供文件浏览对话框,因此我编写了一个 C# dll,其中包含一个在由自定义操作调用时调用标准 OpenFileDialog 的方法。然而,虽然这在 Win2003 中运行良好,但自定义操作在 Windows 7 上运行时只是挂起。它似乎一直到 ShowDialog() 调用然后停止。作为测试,我编写了一个单独的 Windows 窗体应用程序,其中包含一个对话框和按钮来调用 OpenFileDialog,正如预期的那样,效果很好。我只是无法让 OpenFileDialog 从我的 msi 中出现!

我怀疑这可能是一个安全问题,所以我从以管理员身份打开的 msiexec 运行安装程序,但没有区别!

有谁知道如何解决这个问题?

非常感谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

恰似旧人归 2024-09-26 22:49:18
  // 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(); 
  // 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(); 
偷得浮生 2024-09-26 22:49:18

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

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

When I attempted this I found it was popping up behind the other MSI windows. Until I figured this out, it looked just like a hang.

For this and a whole heap of other reasons, I ended up writing a bespoke install mechanism and ditching MSI. Much friendlier on the user and their system in the end.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文