Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6196135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:35:26+00:00 2026-05-24T03:35:26+00:00

I am getting this exception while reading the shapes in excel sheet in c#:

  • 0

I am getting this exception while reading the shapes in excel sheet in c#:
on code line of

if (worksheet.Shapes.Count >= iCurrentRowIndex)
{ }

Unable to cast COM object of type
‘System.__ComObject’ to interface type
‘Microsoft.Office.Interop.Excel._Worksheet’.
This operation failed because the
QueryInterface call on the COM
component for the interface with IID
‘{000208D8-0000-0000-C000-000000000046}’
failed due to the following error: The
application called an interface that
was marshalled for a different thread.
(Exception from HRESULT: 0x8001010E
(RPC_E_WRONG_THREAD)).

Edited:

This application locally running perfect but when i deploy it on IIS , it throws exception. What should the reason? I use code for thread as

string strImageSavedPath = string.Empty;
ThreadStart cbThreadStater = delegate { strImageSavedPath =  CopyToClipBoard(worksheet, (int)iRowindex, strApplicationPath); };
Thread thrd = new Thread(cbThreadStater);
thrd.SetApartmentState(ApartmentState.STA);
thrd.Start();
thrd.Join(); 

Where CopyToClipBoard method reads the image of supplied row index, saves the image in file system and return the path.

System.InvalidCastException was unhandled Message=”Unable to cast
COM object of type ‘System.__ComObject’ to interface type
‘Microsoft.Office.Interop.Excel._Worksheet’. This operation failed
because the QueryInterface call on the COM component for the interface
with IID ‘{000208D8-0000-0000-C000-000000000046}’ failed due to the
following error: The application called an interface that was
marshalled for a different thread. (Exception from HRESULT: 0x8001010E
(RPC_E_WRONG_THREAD)).” Source=”Microsoft.Office.Interop.Excel”
StackTrace:
at Microsoft.Office.Interop.Excel._Worksheet.get_Shapes()
at KGD6ExcelReader.ExcelManager.CopyToClipBoard(Worksheet worksheet, Int32 iRowindex, String strApplicationPath) in
D:\ParallelMinds\Shared\KGD6ExcelReader\KGD6ExcelReader\ExcelManager.cs:line
522
at KGD6ExcelReader.ExcelManager.<>c__DisplayClass3.b__0()
in
D:\ParallelMinds\Shared\KGD6ExcelReader\KGD6ExcelReader\ExcelManager.cs:line
376
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart() InnerException:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:35:28+00:00Added an answer on May 24, 2026 at 3:35 am

    Using Office automation objects from IIS is not recommended and not supported. So the fact that your app runs successfully locally, and unsuccessfully on IIS, is not entirely unexpected.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    That doesn’t mean you can’t try, but make sure you understand everything in the “Considerations for server-side Automation of Office” support article before you proceed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading around trying to find out why I'd be getting this exception
I am getting this exception sometimes while running my Windows Forms app for a
This is the exception that I'm getting when I'm trying to bind to a
I'm getting this problem: PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable
I've been getting this undefined symbol building with this command line: $ gcc test.cpp
I'm getting this error on a compact framework form. code generation for property 'inputControl'
Anyone getting this error when using the new free chart controls MS bought from
I am getting this error now that I hit version number 1.256.0: Error 4
I am getting this error when trying to run internet information services on a
I am getting this error but only very occasionally. 99.9% of the time it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.