"External component has thrown an exception" while working with OpenFileDialog box in C#

Posted by Udaysimha under C# on 4/30/2013 | Points: 10 | Views : 4989 | Status : [Member] | Replies : 2
Hi friends

While working on C# Windows Form application with OpenFileDialog Box i got the "External component has thrown an exception".
Actually open file dialog box is opened while trying to select any thing in that dialog box i got above exception exactly.

System.Data.OleDb.OleDbConnection dbConn = null;
System.Data.OleDb.OleDbCommand cmdCategory = null;
System.Data.OleDb.OleDbDataAdapter oledaCategory = null;
DataSet ds = new DataSet();
string fileName = String.Empty;

try
{
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
OpenFileDialog opendialog = new OpenFileDialog();
DialogResult diaResult;
opendialog.Filter = "CSV files(*.csv)|*.csv";
opendialog.FilterIndex = 1;
opendialog.Title = "Select the csv file to be import";
opendialog.RestoreDirectory = true;
diaResult = opendialog.ShowDialog();
switch (diaResult)
{
case DialogResult.OK:
fileName = opendialog.FileName;
break;
case DialogResult.Cancel:
break;
}
if (String.IsNullOrEmpty(fileName))
return;
string connString = string.Empty;

i add this reference to project
Microsoft.Office.Interop.Excel
Microsoft.Office.Tools.Excel.v9.0

Please help me to find out what i am doing wrong or missing something here.

Thanks in advance.

uday


Responses

Posted by: Jitendrasoft09 on: 4/30/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi,
You have to create the object of DialogResult like that DialogResult diaResult=new DialogResult ,then you initialize the openfiledialog object, please refer below link that would be helpful for you.
http://visualbasic.ittoolbox.com/groups/technical-functional/vb-dotnet-l/openfiledialog-not-showing-correctly-on-showdialog-4212716

Jitendra Kumar
If my post helps you, plz mark as an answer.

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Udaysimha on: 5/1/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Jintendra

Thanks for your reply.
But that did`t help to resolve issue.

uday

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response