C#WPF OpenFileDialog导致XP中崩溃,而不是Vista中 [英] C# WPF OpenFileDialog causing crash in XP, not in Vista
问题描述
我有一个WPF应用程序,该程序可以在我的Vista开发计算机上正常运行,但不能在生产XP机器上运行.唯一的问题是调用OpenFileDialog.Show().一旦我调用该方法,该应用程序就会在XP盒中终止.
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.
该问题不会触发异常. (我已经将该块包含在try-catch块中,但无济于事.)当我单击File-> Open应用程序时,刚好在XP中退出.有趣的是,我可以使用File-> Save并使用Save As对话框将文件写入磁盘.我曾尝试将其构建为.Net 3.0和3.5,但没有任何区别.
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.
我已经尝试了Microsoft.Win32.OpenFileDialog和System.Windows.Forms.OpenFileDialog并得到完全相同的症状.
I've tried both Microsoft.Win32.OpenFileDialog and System.Windows.Forms.OpenFileDialog and get the exact same symptom.
Microsoft.Win32变体的代码块:
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!)
推荐答案
感谢您的建议.我验证了注册表权限和完全信任问题.事实证明,尽管我专门针对.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.
这篇关于C#WPF OpenFileDialog导致XP中崩溃,而不是Vista中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!