Click here to Skip to main content
11,502,201 members (61,032 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB6 C# .NET COM
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 :
        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.
Posted 11-Jun-12 6:50am
Vitaly Tomilov at 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 at 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.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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

Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 11 Jun 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100