AutoUpgradeEnabled

My program was failing with MissingMethodException (Method not found: ‘Void System.Windows.Forms.FileDialog.set_AutoUpgradeEnabled(Boolean)’). This happened only on Windows XP and not all of them.

Culprit was obvious. I used OpenFileDialog and I decided to set AutoUpgradeEnabled property. Only problem was that this property was introduced with .NET Framework 2.0 SP1. Notice this service pack part - that property does not exist if you have version without it.

Solution is easy if you are trying setting this property to true - that is default value anyhow. If you want to set it to false, just use reflection:

var property = typeof(FileDialog).GetProperty("AutoUpgradeEnabled");
if (property != null) {
  property.SetValue(openFileDialog1, false, null);
}

Notice that this property is shared among other controls inheriting from FileDialog (e.g. SaveFileDialog) so same thing applies to them also.