Excel 2007 VSTO - Why do I get 0x80010105 upon Excel.Close()?
From time to time (not an each run, but 5th or 6th in a row) I get the following exception at the last line in the code:
Microsoft.Office.Interop.Excel.Workbook wbNew = _ExcelApp.Workbooks.Add(Type.Missing);
wsResults.Copy(Type.Missing, wbNew.Worksheets[3]);
wbNew.SaveAs(string.Format("SummaryView-{0}-{1}.xlsx", segmentId, year),
XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing);
wbNew.Close(false, Type.Missing, Type.Missing);
System.Runtime.InteropServices.COMException: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT)).
Why do I get it and how to fix the problem?
|