Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, friends, I created two threads. Each thread is running separately, but are not running simultaneously. The program stops and displays the error below:

"
C#
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Range'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020846-0000-0000-C000-000000000046}' failed due to the following error: The RPC server is unavailable. (Exception from HRESULT: 0x800706BA).
"

Sometimes it displays following error:

"
C#
The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
"

Please help me to resolve this error.

Thank you.
Posted
Updated 27-Jan-16 0:08am
v2
Comments
Sergey Alexandrovich Kryukov 27-Jan-16 3:06am    
"In parallel" does not have to be "simultaneously". The timing is random. Your exception is totally unrelated to parallelism; this is a casting exception. The question does not make sense, because — what's the use of showing exception message without code which throws that exception. Okay, the answer would be: fix your bug.
—SA
dan!sh 27-Jan-16 3:12am    
What are you doing on those threads?
Member 12235586 27-Jan-16 3:26am    
creating excel files.one thread creates odd numbers excel files.other one creates even numbers files.
dan!sh 27-Jan-16 3:43am    
Are you writing to same file in both threads or you are creating files with different names?
Member 12235586 27-Jan-16 4:27am    
like this
ex:- 1.xls, 3.xls, 5.xls creates by thread_odd
2.xls, 4.xls, 6.xls creates by thread_evan

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900