openfiledialog 的 AutoupgradeEnable 属性

发布于 2024-10-11 22:15:55 字数 509 浏览 6 评论 0原文

我需要在 winform 应用程序中显示打开文件对话框。文件对话框的一个属性,autoupgradeenabled,我将其设置为true,用于根据操作系统更新打开的文件对话框,就像应用程序在 xp 上运行一样然后对话框的显示方式与 wista 或 window 7 中不同。

因此,当我将该属性用作 true 时,并且一旦在装有 带有 2.0 .net 框架的 xp 的计算机中无法打开该打开文件对话框。所以我尝试将其设置为 false,然后也无法使用 xp 和 2.0 框架在计算机中打开它。

然后我尝试通过注释整行意味着我从代码中删除了该属性,然后我试过了,在2.0框架的xp机器上没问题。所以问题是我无法理解为什么该属性无法通过将其设置为 false 或 true 来工作。因为通过设置该属性应该适用于所有框架的所有操作系统,并且对话框应该根据操作系统进行更改。如果不是,那么该属性的含义是什么?

I had need of showing open file dialog in winform application. And one property of the file dialog, autoupgradeenabled which I set as a true, which is for updating the open file dialog according to operating system, like if application is running on xp then dialog is displayed different as in wista or window 7.

So when I used that property as a true, and once in the machine where there was xp with 2.0 .net framework that open file dialog could not be opened. So I tried by doing it false then also it could not be opened in the machine with the xp and 2.0 framework.

Then I tried by commenting that whole line means I removed that property from the code, then I tried and it was fine in xp machine with 2.0 framework. So problem is I cannot understand that why that property is not working by setting it false or true. Because by setting that property is should work in all os with all framework and dialog should be changed according to os. If not,then what is the meaning of that property ?

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

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

发布评论

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

评论(1

﹏雨一样淡蓝的深情 2024-10-18 22:15:55

它不起作用,因为直到 .NET 2.0 SP1 才添加 AutoUpgradeEnabled 属性。

文档 将支持的版本列出为:

.NET 框架: ;版本 4、3.5 SP1、3.0 SP1、2.0 SP1
.NET Framework 客户端配置文件:版本 4、3.5 SP1

在版本 2.0 SP1 之前,使用新的 Windows Vista 样式对话框自动显示 OpenFileDialogSaveFileDialog。直到后来才添加了使用 AutoUpgradeEnabled 属性选择退出此功能的功能。 (MSDN 参考)这并不是一个重大更改,因为

根据 Brandon Turner 关于该主题的博客文章,您将获得 MissingMethodException 尝试在早期版本的框架上使用它时。因此,通过尝试设置该属性(设置为 True 或 False),您会导致程序抛出异常。正如您所描述的那样,评论并删除该行可以让一切正常工作。

It didn't work because the AutoUpgradeEnabled property wasn't added until .NET 2.0 SP1.

The documentation for that property lists the supported versions as:

.NET Framework:                       versions 4, 3.5 SP1, 3.0 SP1, 2.0 SP1
.NET Framework Client Profile:  versions 4, 3.5 SP1

Prior to version 2.0 SP1, the OpenFileDialog and SaveFileDialog were automatically displayed using the new, Windows Vista-style dialogs. The ability to opt out of this with the AutoUpgradeEnabled property wasn't added until later. (MSDN Reference) This wasn't a breaking change because the default setting for that property remained "True" when it was added to later versions.

According to Brandon Turner's blog entry on the subject, you'll get a MissingMethodException when trying to use it on an earlier version of the Framework. Thus, by trying to set the property (to either True or False), you caused the program to throw an exception. Commenting and removing that line allowed everything to work fine, just as you described.

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