Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

OpenFileDialog unhandled System.AccessViolationException only over Windows 7 (32bits)

$
0
0

Hello,

I have an application that works perfectly under Windows XP (32bits) and under Windows 7 (64bits) but that when user try just to open a "OpenfileDialg" crash suddenly and the application closes without any execption message under Windows 7 (32 bits).

Review the "Event Vierwer" of the system I notice that application crash due to an ".NET Runtime Error" 

Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at System.Windows.Forms.FileDialogNative+IFileDialog.Show(IntPtr)
   at System.Windows.Forms.FileDialog.RunDialogVista(IntPtr)
   at System.Windows.Forms.FileDialog.RunDialog(IntPtr)
   at System.Windows.Forms.CommonDialog.ShowDialog(System.Windows.Forms.IWin32Window)
   at System.Windows.Forms.CommonDialog.ShowDialog()


I have looking for a lot of WorkAround that suggest for example to put "[STAThread]" at the Main process, and I have it, ... or put the "ValidateFile" property of the control to false, but It does not work, try to use "RestoreDirectory" property ... 

I have try too to set an initial directory folder with right permission, but ... It does not works, here is my simply code that it is invoked clicking on a simple button:

I use Visual Studio 2010 professional under Windows 7 (64 bits) for develop.... my solution is compiled in FrameWork4 and as "x86" application.

Any help would be very appreciated, thanks a lot.

Francisco Morales

        private void cmdConfigFile_Click(object sender, EventArgs e)
        {
            this.OpenATCommandsWithDialog();
        }

private void OpenATCommandsWithDialog() { this.openFileDialogATCommands = new OpenFileDialog(); Environment.CurrentDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); this.openFileDialogATCommands.InitialDirectory = Environment.CurrentDirectory; try { MessageBox.Show("before"); DialogResult dlgResult = this.openFileDialogATCommands.ShowDialog(); MessageBox.Show("after"); } catch (Exception e) { MessageBox.Show(e.Message); } }



fmorales




Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>