I copied a OpenFileDialog from one of my other projects but it does not work on the new project.
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Binary|*.bin";
open.RestoreDirectory = true;
open.Multiselect = false;
try
{
if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
//some code
}
}...
The Error says that I'm missing a reference. So i tried to configure the references, but when i click the checkbox for System.Windows.Forms it says that I can not use it because the ActiveX-Library was importet from a .NET-Assembly and that it can not be added. In my previous project i added the reference and everything works fine. How can i add a reference to a .NET-Assembly?
Bonus: Why is this happening? Is there any reason why adding a reference should be blocked within VisualStudio?
-Edit- It is a WPF-App and I am using VisualStudio 2017 with .NET Framework 4.5.2
Try replacing the winform reference with false.
Change this
if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
to this
if (open.ShowDialog() == true)