tags:

views:

206

answers:

4

I'm developing an ActiveX EXE that exposes an specific class to a third-party software. This third-party software instanciates an object of this class and uses its methods.

Strangely, this third-party software destroys its object of my exposed class as soon as it calls an specific method, but I have no idea why this happens.

The only clue I have is that this method is the only one that returns a value. All the other ones are simple 'subs' that do not return any value, and when they are called nothing wrong happens.

I'm using VB6.

Do you guys have any idea of why it's happening?

A: 

Your object gets "destroyed" when the last reference to it is deleted. Thats normal COM behavior. Or is your object dying unexcepted and the third-party app is getting an activex error?

Some more questions:)

  • I don't know what you mean with "data server"?
  • Do you have access to the source code of the third-party app?
  • Are you sure, the third-party app holds a reference to your object?
  • Is your objects Class_Terminate Method called?

EDIT: OK, when Class_Terminate is getting called its obvious, that the third-party app has dropped its reference to your object.

Jan
A: 

It should not be deleted, since it's a data server to the third-party app. The third-party app does not get an error.

Mario Marinato -br-
I don't know what you mean with "data server". Do you have access to the source code of teh third-party app?Are you sure, the third-party app holds a reference to your object?Is your objects Class_Terminate Method called?
Jan
A: 

As Jan stated in COM it is normal, that your object is terminated if no one is referencing it. If you would like to do some kind of caching (e.g. keep the DB connection open), you can use a global variable defined in a bas-module.

basGlobal.bas:

Global AGlobalVariable As Object

Connector.cls

Public Function GetFoo() As Object
  If AGlobalVariable Is Nothing then
    Set AGlobalVariable = ...
  End If 
  Set GetFoo = AGlobalVariable
End Function
dummy
A: 

Jan, here are the answers:

  • The third-party app tells my activex that it needs some data. After retrieving that data from web services, my activex will send back data to the app through a callback interface.
  • No, I don't have access to the source code of the third-party app.
  • Yes, I'm sure it holds a reference to my object, because all of its methods work fine.
  • Yes, my Class_Terminate method is called.


Dummy, I can't keep a global instance because when the third-party app destroys its instance of my object, I need to close my application. When I close it, the third-party app then restarts my activex exe.

I know this is strange, but when the object is destroyed, the app tries to create another one, but 'complains' that a previous activex exe is already running. That's why I need to close it.

Mario Marinato -br-