|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
AccessViolationException openning Excel Work Bookcan anyone tell me why the folowing statement throws an AccessViolationException ? my developing pc is WinXP Pro with MSOffice2003 and the release version runs on Windows 2000 Pro with Office2000 while my client can't change his configuration. The Debug version does not throw the exception but the release version throws. wrkBook = appClass.Workbooks.Open( ((myItem)fileList[i]).filepath, 2, false, missing, missing, missing, true, XlPlatform.xlWindows, missing, missing, true, missing, false, false, XlCorruptLoad.xlNormalLoad ); ============================================================ here is my full method body ============================================================ public void converXLS2CSV(ToolStripProgressBar tpBar, ToolStripStatusLabel tsLabel, ToolStripStatusLabel tsLabel2) { // Marge all the stored Excel files into one Excel // file so that query can be executed very easily. // Necessary variable dicleration; Blog(4);log("setting status text"); tsLabel.Text = "Starting ..."; Blog(5);log("creating application class"); appClass = new ApplicationClass(); Blog(6);log("initializing progressbar"); initializeProgressbar(tpBar, fileList.Count, ProgressBarStyle.Continuous); Blog(7);log("entering for loop"); for(int i = 0 ; i< fileList.Count; i++) { Blog(8);log("loop count:" + i.ToString()); if (((myItem)fileList[i]).check.Checked) { Blog(9);log("fileList[" + i.ToString() + "] is checked"); Blog(10);log("Showing status information"); // showing status information tsLabel.Text = "Converting ..."; Blog(11);log("setting tsLabel2.Text"); tsLabel2.Text = ((myItem)fileList[i]).check.Text; Blog(12);log("refreshing the label parent"); tsLabel2.GetCurrentParent().Refresh(); Blog(13);log("getting special directories"); // Creating the converted name of the file string convertedCSV = SpecialDirectories.Temp + @"\" + Path.GetFileNameWithoutExtension(((myItem)fileList[i]).filepath) + ".csv"; Blog(14); //------------------------------------------------------------------------------ // here throws the AccessViolationException //------------------------------------------------------------------------------ log("openning workbook:" + ((myItem)fileList[i]).filepath.ToString()); // Openning the workbook wrkBook = appClass.Workbooks.Open(((myItem)fileList[i]).filepath, 2, false, missing, missing, missing, true, XlPlatform.xlWindows, missing, missing, true, missing, false, false, XlCorruptLoad.xlNormalLoad); bug("Opening file :\n" + ((myItem)fileList[i]).filepath+"\nDeleting file:\n"+convertedCSV); Blog(15);log("deleting the existing file"); // Delete the file if it exists if (File.Exists(convertedCSV)) { File.Delete(convertedCSV); } Blog(16);log("Saving the workbook"); // Saving the workbook as csv file wrkBook.SaveAs(convertedCSV, XlFileFormat.xlCSVWindows, false, false, missing, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlOtherSessionChanges, false, missing, missing, false); Blog(17);log("Closing the workbook"); // Closing the workbook wrkBook.Close(false, ((myItem)fileList[i]).filepath, missing); // Changing the stored file path //((myItem)fileList[i]).filepath = convertedCSV; } Blog(17);log("Performing animation"); // Performing animation tpBar.PerformStep(); } Blog(18);log("Resetting the progressbar to it's initial position"); // Resetting the progressbar to it's initial position resetProgressbar(tpBar); Blog(19);log("qUITING APPLICATION"); appClass.Quit(); } By the way, I did not catch any exception becoz first i have to make a clear line of execution then I shall appy all the exception. That's how I code. please help me ! |
|||||||||||||||||||||||