C# WPF OpenFileDialog 在 XP 中导致崩溃,但在 Vista 中则不然

发布于 2024-09-15 19:32:43 字数 1354 浏览 9 评论 0原文

我有一个 WPF 应用程序,可以在我的 Vista 开发计算机上正常运行,但不能在生产 XP 机器上运行。唯一的问题是调用 OpenFileDialog.Show()。一旦我调用该方法,应用程序就会在 XP 盒子上终止。

该问题不会触发异常。 (我已将该块包围在 try-catch 块中,但无济于事。)当我单击“文件”->“打开”应用程序并在 XP 中退出时。有趣的是,我可以使用“文件”->“保存”并使用“另存为”对话框将文件写入磁盘。我尝试将其构建为 .Net 3.0 和 3.5,但没有什么区别。

我尝试过 Microsoft.Win32.OpenFileDialog 和 System.Windows.Forms.OpenFileDialog 并得到完全相同的症状。

Microsoft.Win32 变体的代码块:

try  
{  
    OpenFileDialog ofd = new OpenFileDialog();
    if (ofd.ShowDialog().Value)
    {
        //do something
    }
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString(), "Error!");
}

我拥有的唯一线索是安全事件日志中的以下(部分)条目。

Event Type:     Failure Audit
Event Source:   Security
Event Category: Object Access
Event ID:       560
Description:
Object Open:
        Object Server:  Security
        Object Type:    Key
        Object Name:    \REGISTRY\MACHINE\SOFTWARE\Microsoft\EnterpriseCertificates\Disallowed
        Accesses:       DELETE
                        READ_CONTROL
                        WRITE_DAC
                        WRITE_OWNER
                        Query key value
                        Set key value
                        Create sub-key
                        Enumerate sub-keys
                        Notify about changes to keys
                        Create link

有什么想法吗? (拜托!)

I have a WPF application that runs fine on my Vista development machine, but not on the production XP boxes. The only problem is with a call to OpenFileDialog.Show(). As soon as I call the method, the application is terminated on the XP box.

The problem does not trigger an exception. (I've surrounded the block in a try-catch block to no avail.) When I click on File->Open the application just up and quits in XP. Interestingly, I can write files to disk with File->Save and using the Save As dialog. I've tried building it to .Net 3.0 and 3.5 but it doesn't make a difference.

I've tried both Microsoft.Win32.OpenFileDialog and System.Windows.Forms.OpenFileDialog and get the exact same symptom.

The code block for the Microsoft.Win32 variant:

try  
{  
    OpenFileDialog ofd = new OpenFileDialog();
    if (ofd.ShowDialog().Value)
    {
        //do something
    }
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString(), "Error!");
}

The only clues I have is the following (partial) entry from the security event log.

Event Type:     Failure Audit
Event Source:   Security
Event Category: Object Access
Event ID:       560
Description:
Object Open:
        Object Server:  Security
        Object Type:    Key
        Object Name:    \REGISTRY\MACHINE\SOFTWARE\Microsoft\EnterpriseCertificates\Disallowed
        Accesses:       DELETE
                        READ_CONTROL
                        WRITE_DAC
                        WRITE_OWNER
                        Query key value
                        Set key value
                        Create sub-key
                        Enumerate sub-keys
                        Notify about changes to keys
                        Create link

Any ideas? (Pleeeease!)

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

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

发布评论

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

评论(3

陌上青苔 2024-09-22 19:32:43

谢谢你的建议。我验证了注册表权限和完全信任问题。事实证明,尽管我专门针对 .Net 3.0(基于标准组织映像)构建了我的应用程序,但我仍然不完全理解对 .Net 3.5 SP1 的依赖。我的问题的解决方案是在所有受影响的计算机上安装 .Net 3.5 SP1。

我只是想关闭循环。再次感谢所有贡献想法的人。

Thanks for the advice. I verified both the registry permissions and the full-trust issue. It turns out that, although I specifically built my application to .Net 3.0 (based on the standard organizational image), there was a dependency on .Net 3.5 SP1 that I still don't fully understand. The solution to my problem was to install .Net 3.5 SP1 on all the affected computers.

I just wanted to close the loop. Thanks, again, to all who contributed ideas.

作妖 2024-09-22 19:32:43

看来注册表项存在权限问题。我的第一个建议是检查该密钥的权限并验证 ACL 是否正确(最好将它们与应用程序正在运行的另一个 XP 盒子进行比较)。

如果权限正常,那么您应该尝试重新安装.NET(也许安装程序会重置注册表项上的一些所需权限)。

如果一切都失败了,请在有问题的机器上重新安装 XP,除非有人有更好的主意。

It seems there is a permission problem with the registry key. My first suggestion would be to check the permissions on that key and verify that the ACL's are correct (best compare them to another XP box where the app is working).

If the permissions are OK, then you should try reinstalling .NET (maybe the installer will reset some required permissons on the registry keys).

If all else fails, reinstall XP on problematic machines, unless someone has a better idea.

飘然心甜 2024-09-22 19:32:43

您的生产程序集似乎并未在完全信任的情况下运行。您是否从网络共享运行?

It doesn't appear your production assembly is running under full trust. Are you running from a network share?

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