Click here to Skip to main content
Rate this: bad
good
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.
Michel
Posted 11-Jun-12 7:50am
Comments
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.
Michel

1 solution

Rate this: bad
good
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 215
1 George Jonsson 175
2 Kornfeld Eliyahu Peter 159
3 PIEBALDconsult 110
4 Richard MacCutchan 85
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 11 Jun 2012
Copyright © CodeProject, 1999-2014
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