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 7942061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:51:10+00:00 2026-06-03T23:51:10+00:00

I have to communicate with a third party application and the only way to

  • 0

I have to communicate with a third party application and the only way to do so is by accessing the provided COM component. Because the interaction takes about 3 minutes it’s mandatory that it takes place in the background.
So what i tried to do is to add a reference the component with option “embedd interop-types” = true and to create a test that reads very basic data through the interface. The documented way to do so is by following Code:

System sys = new System();
if(Convert.ToBoolean(sys.Initialize()) && Convert.ToBoolean(sys.Login("John Smith", out userInstance)))
Project proj = new Project();
if (Convert.ToBoolean(proj.Open(sys, m_projName, m_scenarioName)))
    someValue = proj.Name;

this works perfectly until the BackgroundWorker is used. Then I get following error in the first line of code:

Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘ICAPILib.System’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{1F5EB3E2-35F6-11D2-A191-0060083A260B}’ failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

I already tried ReRegistering the Component without any success.

When using the BackgroundWorker the Thread Apartment Type obviously is MTA. The COM component has ThreadingModel set to apartment. If I understood this article
http://msdn.microsoft.com/en-us/library/eaw10et3.aspx
correctly the interop marshalling should take care of accessing the Objects.

Does anybody have a clue what I could try to make this work?

  • 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-06-03T23:51:12+00:00Added an answer on June 3, 2026 at 11:51 pm

    What has happenned is that the COM Marshaller was unable to marshal the object.

    First answer: Standard marshalling requires a type library. It may be that the object’s type library is not correctly registered, hence the error. Are you on x86 or x64? Try registering the library with REGTLB.

    Second answer: If that doesn’t work, the easy answer is to use a thread of STA apartment type. This may mean you cannot use a BackgroundWorker but may have to use a specially created thread which you destroy when completed. If we are talking about a three minute operation, the additional overhead is negligible.

    Note the object must be created on the thread from which it is to be used, and the apartment type msut be compatible with the object’s threading model, to avoid marshalling.

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

Sidebar

Related Questions

I have an application that I am writting that communicates with a third-party program
I am developing an application to communicate with a third party application through socket.
Here is my problem: I have a closed-source third-party Win32 application, which acts as
I have 32 bit application using 32 bit third party library. Now I have
I have a third party java program called kgsgtp.jar which need to communicate with
I have an application that I was writing that communicates with a third-party application
I have a game server application (Java) and want to have PHP communicate directly
I have an application that uses rest to communicate to a server, i would
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
I have a Linux process developed by a third-party that communicates with a terminal.

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.