[BUG] System::Windows::Forms::OpenFileDialog::AutoUpgradeEnabled does not work correctly with NetCore 8.0

Pierre Chatelier 81 Reputation points

When setting AutoUpgradeEnabled to false in an System::Windows::Forms::OpenFileDialog

  • everything goes right in a .Net 4.8 project
  • no filenames are returned when exiting the dialog in a .Net 8.0 project (netcore8.0-windows)

To be able to use System::Windows::Forms::OpenFileDialog in a NetCore 8.0 project, <UseWindowsForms>true</UseWindowsForms> must be used.

I don't know if it's relevant, but I have also referenced Microsoft.Windows.Compatibility in my project.

Is there any workaround ?

I need this feature to use customized dialogs.

My reproducer :

System::Windows::Forms::OpenFileDialog^ openFileDialog = gcnew System::Windows::Forms::OpenFileDialog();
openFileDialog->AutoUpgradeEnabled = false;
openFileDialog->Title = "Load...";
openFileDialog->AddExtension = true;
openFileDialog->Multiselect = true;
openFileDialog->DefaultExt = "cfg";
System::String^ filterString = "";
filterString += System::String::Format("{0}{1}",
  System::String::IsNullOrEmpty(filterString) ? "" : "|",
  "Cfg files" + " (*.cfg)|*.cfg");
filterString += System::String::Format("{0}{1}",
  System::String::IsNullOrEmpty(filterString) ? "" : "|",
  "All files" + " (*.*)|*.*");
openFileDialog->Filter = filterString;
System::Windows::Forms::DialogResult code = openFileDialog->ShowDialog(this);
//select one or a few files
System::Console::WriteLine("selected count = {0}", openFileDialog->FileNames->Length);//returns 0

If you can't reproduce I can send you a minimum project

Microsoft Technologies based on the .NET software framework.
3,156 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,441 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pierre CHATELIER 11 Reputation points
    0 comments No comments