0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) exception occurs when creating object of Excel in c#

0

I am working on an excutable written in C#, which basically opens an existing Excel file (in C# using Microsoft.Office.Interop.Excel dll) and do some manipulation over it. Code works fine for my user account, but when I run the same code under a different user(admin role) then it throws an exception at the line of _excel = new Application();

_excel = new Application(); // throws an exception
_excel.Visible = _showExcel;

Following is the exception details -

System.Runtime.InteropServices.COMException: Creating an instance of the COM component with CLSID {00024500-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 8001010a The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)

In task manager, i can see Excel process after this exception occured.

Using Computer Management>System Tools>Local Users and Groups>Groups>Administrators , I confirmed that user is in admin role.

I am running Exe file using powershell command prompt (openning as a different user)

I already googled a lot of pages related to this error, but I did not get any success related to my specific issue.

c#
.net
excel
com-interop
asked on Stack Overflow Dec 10, 2017 by user12181 • edited Dec 23, 2017 by Ken Kin

1 Answer

1

this exception is thrown because Excel is busy and will not service any Object Model calls. try following code:

 xlWorkSheet.EnableSelection = xlWorkSheet.EnableSelection = Microsoft.Office.Interop.Excel.XlEnableSelection.xlNoSelection;

and if will not work follow microsoft solution

answered on Stack Overflow Dec 10, 2017 by Aref Zamani

User contributions licensed under CC BY-SA 3.0