C# application using Microsoft.Office.Interop.Excell dll throws exception(error: 80080005) when Windows trusted apps is installed with OS installation

1

Issue: I am facing an issue in Win10 PC while running a C#application created in VS 2013. The application always throws exception when it tries to create excel instance. Microsoft.Office.Interop.Excel is added in project reference(:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15\Microsoft.Office.Interop.Excel.dll)

The below Exception is obtained:

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))

From event viewer I see the error related to excel.exe version 16 bing called:

Faulting application name: EXCEL.exe, version: 16.0.8528.2136, time stamp: 0x59d6c372
Faulting module name: KERNELBASE.dll, version: 10.0.16299.371, time stamp: 0xee297154
Exception code: 0xc06d007f
Fault offset: 0x00103ef2
Faulting process id: 0x2c8c
Faulting application start time: 0x01d41f1db8e05601
Faulting application path: C:\Program Files\WindowsApps\Microsoft.Office.Desktop.Excel_16000.8528.2136.0_x86__8wekyb3d8bbwe\Office16\EXCEL.exe
Faulting module path: C:\windows\System32\KERNELBASE.dll
Report Id: 5c23fa18-770c-4233-b803-e57c2bf68174
Faulting package full name: Microsoft.Office.Desktop_16000.8528.2136.0_x86__8wekyb3d8bbwe
Faulting package-relative application ID: Excel

Code snippet: The application is trying to create an instance of Microsoft.Office.Interop.Excel.Application:

    public ExcelReader()
    {
        try
        {
            m_excelApplication = new Microsoft.Office.Interop.Excel.Application();
        }
        catch(System.Exception Exp)
        {
            MessageBox.Show( Exp.Message );
        }
    }

Environment details: During OS installtion there is something called trusted apps which is installed by default. We can see the icons related to Excel 2016, Word 2016 etc in Windows option. But in my machine only Office 2013(64 bit) is installed after fresh OS installation.I have the exe for MS office 2013 present in "C:\Program Files\Microsoft Office\Office15\EXCEL.EXE"

Why is the excel.exe version 16(C:\Program Files\WindowsApps) called when application launches

Issue is observed in machines which have MS office 2016, MS office 2013 installed which has the trusted apps(2016) installed by default.

Could somebody help me out on this.

c#
excel
windows-store-apps
ms-office
asked on Stack Overflow Jul 20, 2018 by Deeps • edited Jul 20, 2018 by Dominique

2 Answers

1

After hours and hours of searching the web for an answer regarding this issue, I have found that under Component Services > Computers > My Computer > DCOM Config > Microsoft Excel Application >> Properties panel - [Identity tab], the default setting for Windows 10 is The launching user, while on Windows 7 the default one is The interactive user. Changing the identity setting on Windows 10 to The interactive user solved this issue for me. Hope this will save other people the amount of time it took me to find an answer.

answered on Stack Overflow Aug 8, 2019 by Sebastian
0

This issue happens because of Interop libraries. The Interop libraries have different methods in different versions. You have to check the version of Interop libraries that you currently have and use appropriate libraries that you need for current Office that is installed.

On that Microsoft page you can see the information where you can get Introp libraries for installed office version.

If you want to support multiple office versions, you have to install the minimal version that you clients can have (2010 for example) and then write proxy classes that will detect version of MS Office and use their functionality and methods via CLSID.

answered on Stack Overflow Jul 20, 2018 by Aliaksei Futryn

User contributions licensed under CC BY-SA 3.0