Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello everyone.

I have a com object written in c++ (based on IDispatch interface). I can create an instance happily in vb6 and even in c# (VS2010).

The problem is the following:
I have a console application which handles an instance of my object.
The goal is to launch a vb6 activex.dll with this object passed via a method of this activex.dll which display a form. It works fine but when I quit the function responsible of the activex instantiation, I got a locking effect when I click on a button on the form to access to my object instance assigned to a variable locally.

How could I solve this interlock situation. I was hoping to use xxx.invoke(...) but object or Type do not have this method.

I suppose this is related to managed and un-managed code but does not know actually how to solve that issue.

To create the master COM object I am using :
C#
private bool CreateCOMObject(string ComponentClassName)
{
    bool bRet = false;

    _VB6DocType = System.Type.GetTypeFromProgID(ComponentClassName);
    _VB6Control = System.Activator.CreateInstance(_VB6DocType);

    bRet = true;

    return bRet;
}


Maybe do you have already encontoured such an issue ?
Thank you very much in advance.
Best regards.
Michel
Posted
Comments
Vitaly Tomilov 11-Jun-12 13:10pm    
Is the form a modal dialog box? There are some issues invoking a modal dialog from a COM library, which results in a lock, if you invoke a UI-thread object from a non-UI COM thread.
SuperMiQi 11-Jun-12 14:32pm    
Hello Vitaly,

The main application is a console application.
Inside the activex.dll (vb6) project, I launch the form like: frm.Show 0

During the init class phase, I can access to my main object but once the form is complete and the console application is in idle mode, I get the locking effect.

Any ideas are welcome.

Thank you very much in advance.
Best regards.
Michel

1 solution

I'd *guess* it's an apartment threading issue

Have a look at Use STA COM Objects Asynchronously[^] or change the threading model on your object
 
Share this answer
 

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