openFileDialog - AccessViolationException was unhandled

Paranthaman 1 Reputation point
2021-10-04T23:22:32.89+00:00

Hi,
Iam using Vs2015, While I try to Open a file using OpenFileDialog, Iam receiving the error

"Unhandled exception of type" System.AccessViolationException" occoured in system.windows.forms.dll
Additional information: Attempted to read or write protected memory.This is often an indication other memory is currupt.

My Codes
[code]
openFileDialog1->Title= "Select Your Excel File";
openFileDialog1->InitialDirectory = "C:\";
openFileDialog1->Filter = "Excel Files (.xls)|.xls|All files (.)|.";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK) {
MyExcelFile = openFileDialog1->FileName;
}[/code]

Developer technologies | Windows Forms
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.