Excel interop - remote procedure call failed or RPC_E_SERVERFAULT

4

We have a C# application that internally invokes excel. It does so using Microsoft.Office.Interop.Excel.dll. The application works on most computers with Excel, but not on mine.

Originally, the application was failing with HRESULT 0x800706BE (The remote procedure call failed). I'd tried almost every advice found on the web, but without success. Then I uninstalled my MS Office 2013 Pro, and installed Office 365 v2013. The application still fails on the same line of code, but now with HRESULT 0x80010105 (RPC_E_SERVERFAULT).

Is there any advice you can give to make the excel interop working? My guess is that some Windows service is not started or a DCOM component is not registered. But I don't know which one.

Details:

  • Windows 7 x64, MS Office 2013 Pro/365 ProPlus
  • It is a C# application. It is compiled with VS2010 for .NET 4.0, but the problem exhibits even when the app is compiled with VS2012 for .NET 4.5. With use of different versions of Microsoft.Office.Interop.Excel.dll.

There are three facts I consider important:

  • The application works on other computers, so it is not the application what is a cause of the problem.
  • The application doesn't work even after re-installation of (a slightly different version of) excel (2013), so it is probably not a problem of excel itself.
  • I used the SysInternals' ProcessMonitor to find out that the application really succeeds in instantiating the excel, and the excel successfully(?) reads the .xlsx file. But then excel fails.

I also used the VS2010 debugger to find out what's going on:

  • This is the core of the code. It fails on the last line in Open:

    using Excel = Microsoft.Office.Interop.Excel;
    object misValue = System.Reflection.Missing.Value;
    
    Excel.Application myExcelApp = new Excel.Application();
    myExcelApp.Visible = false;
    myExcelWorkbooks = myExcelApp.Workbooks;
    myExcelWorkbook = myExcelWorkbooks.Open(xlsxFileFullPath, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
    
  • There is nothing relevant in the Windows event log (at the time the app fails).

  • Here are some of the links I found, but there are no suggestions given, or they didn't help: link1, link2,... (cannot post more than 2 links)
microsoft-excel
microsoft-office
automation
rpc
asked on Super User Sep 16, 2016 by xarx

2 Answers

11

After a long research I succeeded to solve this problem due to this link. Essentially, the problem was caused by a third-party Excel COM plug-in, in my case it was "FoxitReader PDF Creator COM Add-in". After disabling it, the problem was gone!

How to disable the plugin: Excel > File > Options > Add-ins > Manage, then choose "COM add-ins" > Go. And then untick the problematic plugin.

answered on Super User Sep 23, 2016 by xarx
2

I had the exact same issue as xarx. Suddenly an application I created stopped working on certain PCs. The code it was crashing on was:

Dim fname As String = "B:\Data Warehouse\Lists\WarehouseLists.xls"
    Try
        xlWorkBookList = xlAppLists.Workbooks.Open(fname,, False) 'open the raw data sheet
    Catch ex As Exception
        MessageBox.Show(ex.Message)
        Exit Sub
    End Try

Disabling the Foxit Reader add-in immediately fixed the issue.

answered on Super User Dec 13, 2016 by Thomas Bailey

User contributions licensed under CC BY-SA 3.0