VB won't release reference to COM object in use by another proces s 
Author Message
 VB won't release reference to COM object in use by another proces s

I have an ActiveX EXE file that contains a standard module and one
class.  The standard module contains a Private Sub Main procedure for
project start up.  The Sub Main creates a COM object from the class
within the project.

I want the Sub Main to test for the existence of the object in memory
and end execution of the duplicate process (EXE file) if the object is
already active.  The object is designed to continuously Peek, process,
and Receive messages from an MSMQQueue.

My problem is that when I start a second instance of the ActiveX EXE, it
doesn't release the reference to the active object.  I want to ensure
that I don't somehow wind up with multiple instances of the ActiveX EXE
in memory.

Any useful advice would be greatly appreciated.  Here is the code for
the Sub Main:

Option Explicit
Option Compare Text
Private Sub Main()
  On Error Resume Next
  Dim myObj As myProj.myCls
  Set myObj = GetObject("myProj.myCls")
  If myObj Is Nothing Then
    Set myObj = CreateObject("myProj.myCls")
    If myObj Is Nothing Then
        Exit Sub
    End If
    myObj.myMethod
  End If
  Set myObj = Nothing
End Sub



Fri, 26 Jul 2002 03:00:00 GMT  
 VB won't release reference to COM object in use by another proces s
Hi Dan,

You need to give your class a getobject support, ie, adding the instance
into the Running Object Table, so that you can get the reference to the
existing object, otherwise, the getobject will alwayse fail. Please check
MSDN's Give Your Classes GetObject Support, and it give you an explanation,
also you can check  August 97 VBPJ for detailed information.

thanks,

george



Fri, 26 Jul 2002 03:00:00 GMT  
 VB won't release reference to COM object in use by another proces s


Fri, 19 Jun 1992 00:00:00 GMT  
 VB won't release reference to COM object in use by another proces s
I have already read the MSDN article you recommended.  It didn't really
provide any useful information, since I am not a C++ programmer.  If the
article had included the code for the author's "helper objects", that
may have been more informative.

I was also under the impression that this was an outdated article.
Doesn't the current version (VB6 SP3) build ActiveX classes with
built-in support for the GetObject statement?



Fri, 26 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. COM DLL used in ASP page won't release

2. releasing a Com Server reference from Vb.Net

3. COM-Gen 2000 - Build 107 released - generates COM objects

4. COM-Gen 2000 - Build 153 released - generates COM objects

5. COM-Gen 2000 - Build 153 released - generates COM objects

6. COM-Gen 2000 - Build 107 released - generates COM objects

7. Problems with callback reference to a COM object - which isn't a source of events

8. COM-Gen 2000 - Build 153 released - generates COM objects

9. COM-Gen 2000 - Build 107 released - generates COM objects

10. COM-Gen 2000 - Build 153 released - generates COM objects

11. COM-Gen 2000 - Build 107 released - generates COM objects

12. COM-Gen 2000 - Build 153 released - generates COM objects

 

 
Powered by phpBB® Forum Software