سؤال

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 ?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top