I am getting an Exception Error: Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).'

0

I am trying to open an Excel file but have repeatedly gotten the error:

System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).'

I have tried fixing this using multiple posts related to file type or memory, but with no luck so far.

This error comes from the line of code:

     var myExcelApplication = new Excel.Application();

This is most of the code:

public class WriteToParam
    {

        private string excelFilePath = @"""C:\Parameters.xlsx""";
        private int rowNumber = 1;

        Excel.Application myExcelApplication;
        Excel.Workbook myExcelWorkbook;
        Excel.Worksheet myExcelWorkSheet;

        public string ExcelFilePath
        {
            get { return excelFilePath; }
            set { excelFilePath = value; }
        }

        public int Rownumber
        {
            get { return rowNumber; }
            set { rowNumber = value; }
        }

        public void OpenExcel()
        {
            var myExcelApplication = new Excel.Application();
            myExcelApplication.Visible = true;

          }
}

c#
excel
asked on Stack Overflow Sep 18, 2019 by cat • edited Sep 18, 2019 by cat

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0