Issue with launching Excel running programme in c#

Jason Lau 1 Reputation point
2020-11-13T09:35:56.833+00:00

When I try to run a programme in MS visual studio to start excel in the background on my desktop, the two error windows pop up.

Window 1:
Assertion failed!
Program: ...\Microsoft Office\Root\Office16\AppVlsvSubsystems32.dll
File ..\ComRegistry.cpp
Line: 191

Expression: TokenElevationTypeLimited != elevationType

For information on how your program can cause an assertion failure, see the virtual C++ documentation on asserts.

(Press Retry to debug the application - JIT must be enabled.)

Window 2:
Retrieving the COM class factory for component with CLSID {000-24500-0000-0000-C0000-0000000046} failed due to the following error: 8008005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

The error arises only when subprogrammes which call excel are run.

The command which call Excel to start is as follows: Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();

The version of software installed to the desktop are as follows

  • Visual Studio Version: MS Visual Studio express 2015 for windows desktop (ver. 14.0.25123.00 update 2)
  • Excel Version 2002 (Built 12527.21330 Click to Run)
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
939 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,406 Reputation points
    2020-11-16T02:31:09.903+00:00

    Hi JasonLau,

    >Program: ...\Microsoft Office\Root\Office16\AppVlsvSubsystems32.dll

    It seems that your program should work with office 2016 instead of 2002.

    >(Press Retry to debug the application - JIT must be enabled.)

    Please try to go to Tools/Options/Just-In-Time, then enable all types:
    39903-image.png

    >The command which call Excel to start is as follows: Microsoft.Office.Interop.Excel.Application xlapp = new Microsoft.Office.Interop.Excel.Application();

    Please have a try to use Microsoft.Office.Interop.Excel.ApplicationClass Class to call excel app in your C# code

    Best Regards,
    Dylan

    0 comments No comments

  2. Jason Lau 1 Reputation point
    2020-11-16T08:18:14.063+00:00

    Thanks for your reply, but the JIT option cannot be found in the Options tab.

    40055-c-setting.jpg