We are experiencing a strange behavior these past days with Excel server automation using Microsoft.Office.Interop.Excel, Version=126.96.36.199 library.
The problem happened on Office 365 and it is random on the same file (sometimes it works sometimes it is not). The application was working properly for years without any king of issue. The first time we experienced this issue was on 14th January 2020 and by searching online we found out that this coincide with the date of the security update as indicated in this Microsoft page https://docs.microsoft.com/en-us/officeupdates/office365-proplus-security-updates. Any idea how to solve this issue? We tried to analyse Application Event Viewer to see if there is more details about the issue but no meaningful detail was found. The problem randomly occurs on these lines of code:
Application excelApp = new Application(); or later when we open workbook with following line of code: excelApp.Workbooks.Open(fileName, true, true);
This is the exception we get when the process failed on opening workbook:
The remote procedure call failed. (Exception from HRESULT: 0x800706BE) System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed. (Exception from HRESULT: 0x800706BE) at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) at GeneratorEngine.ExcelAddinGenerator.InitializeWorkBook(Int32& winProcessId)