Learning BackgroundWorker - Works in Debug Not After Compile

I have a very simple program I am working on just to get familair with the backgroundWorker class and its functionality. I ran into a wierd problem though when the program worked properly when I debugged from Visual C# 2005 Express Edition but after I build the solution the program throws an error stating: "The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))"

All the program does is goes to a directory, finds all excel files inside of the directory and returns the file names of each file to an array. After backgroundworker completes it puts the file names into a listbox... Works great in debug, not after building.

private string[] filename = null;

public string[] fileNames
{
get { return filename; }
set { filename = value; }
}

private void searchButton_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
searchButton.Enabled = false;
cancelButton.Enabled = true;

if (searchTextBox.Text == "")
{
MessageBox.Show("You must enter a string to perform a search.", "Search Failed");
this.Cursor = Cursors.Default;
searchButton.Enabled = true;
cancelButton.Enabled = false;
}
else
{
listBox1.Items.Clear();
backgroundWorker1.RunWorkerAsync();
}
this.Cursor = Cursors.Default;
}

private void backgroundwork_Compeleted(object sender, RunWorkerCompletedEventArgs e)
{
searchButton.Enabled = true;
cancelButton.Enabled = false;
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
else if (e.Cancelled)
{
MessageBox.Show("The operation was cancelled by the user.", "Cancelled");
}
else
{
if (fileNames != null)
{
listBox1.Items.AddRange(fileNames);
}
}

}

private void searchDirectory_DoWork(object sender, DoWorkEventArgs e)
{

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
string myDir = @"C:\ExcelFiles";
string entStr = "";
string _fnames = null;
int fileCount = 0;
char delim = ',';

excelApp.Application.ScreenUpdating = false;
entStr = searchTextBox.Text;

excelApp.Application.FileSearch.NewSearch();
excelApp.Application.FileSearch.LookIn = myDir;
excelApp.Application.FileSearch.SearchSubFolders = false;
excelApp.Application.FileSearch.FileType = MsoFileType.msoFileTypeExcelWorkbooks;
if (excelApp.Application.FileSearch.Execute(MsoSortBy.msoSortByFileName, MsoSortOrder.msoSortOrderAscending, true) > 0)
{
foreach (string vaFileName in excelApp.Application.FileSearch.FoundFiles)
{
fileCount++;
if (_fnames == null)
{
_fnames = vaFileName;
}
else
{
_fnames = _fnames + "," + vaFileName;
}
}
}
if (_fnames != null)
{
fileNames = _fnames.Split(delim);
}
else
{
MessageBox.Show("There were no files in the folder.", "No Files");
}
}

private void cancelButton_Click(System.Object sender, System.EventArgs e)
{
this.backgroundWorker1.CancelAsync();
cancelButton.Enabled = false;
searchButton.Enabled = true;
}

Thanks in advance for your help!

[3456 byte] By [mEt] at [2007-12-25]