I’ve got an application that has to be compiled to x86 because of some old COM controllers to very old 3rd party software drivers.
I have noticed that anytime I call a Form’s Modal Dialog Box while some other application has focus (like the Visual Studio code that I am stepping through), that Dialog Box is brought up behind the parent window.
private string Locate(string filename) {
if (!File.Exists(filename)) {
using (OpenFileDialog dlg = new OpenFileDialog()) {
dlg.FileName = filename;
if (dlg.ShowDialog(this) == DialogResult.OK) {
return dlg.FileName;
}
}
}
return filename;
}
I can compile the application as x64, but loading the COM drivers will fail, causing the application to never start.
Has anyone else noticed this behavior from (Visual Studio, the .NET Framework, or Windows 7)? If not, then I must have something screwy going on in my code elsewhere.
Is there a way to “fix” it?
VS2010 defaults to x86 so your configuration is quite common which would suggest you do have something screwy going on with your code.
Are you sure that this as in dlg.ShowDialog(this) is actually the parent and is visible etc?
Is Locate being called from a non-UI thread? If not, did you try using dlg.ShowDialog().