Solved

ActiveX reference count

Posted on 1998-01-21
4
283 Views
Last Modified: 2013-12-03
Hello, I checked the following structure:
console application(process 1) call ActiveX exe(process 2), I'll call it exe1.
the ActiveX exe call ActiveX dll, I'll call it dll1, the dll call a nother ActiveX exe, called exe2.

reference count is r.c.

1. r.c in console for exe1 is 1 and in exe1 it is 4, why ?
2. passing this from exe1 to dll to exe2 and assigning a smart pointer to it increase r.c to exe by 2 and both exe and exe2 stay up. why ?
3. like 2, only the passed argument to exe2 is this from the dll. this time none of the processes stays, but r.c count jumps from 1 to 4 (the dll count) in the dll.

so, the problem is how do the r.c done between processes
and in them ? when a process will stay up ?

many thanks,
   Gilad
0
Comment
Question by:gilad111397
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 240 total points
ID: 1410216
An object cannot be terminated or shut down while there are references to it.

Or until all references to an object are released, the object will continue to live.

So there can be a situations where if an object has a reference to another object and that object has a reference to the original object, then they cannot shut down properly. The only way around this is to hard code one of the objects so that when a request to shut down comes in, the object shuts down regardless of the reference count.

Normally, if you have two objects that must do this, it is better to create a third object which is a manager object. The manager object that passes out resource references to the original objects. This way, the objects don't hold reference counts to each other, but to the manager object. Makes shutting down much easier.


0
 

Author Comment

by:gilad111397
ID: 1410217
Ok, suppose we use an object manager which hold two ActiveX exe objects (exe1 and exe2). When exe1 wants to refer exe2, the manager send to it a pointer to exe2. When I assign a smart pointer (IDispatchPtr, for instance) to the argument which was received from the manager (IDispatch *), that's it, the processes will stay up.
What is wrong here ?
0
 

Author Comment

by:gilad111397
ID: 1410218
The smart pointer is defined as global variable.
0
 

Author Comment

by:gilad111397
ID: 1410219
Also, last clarification, I read about CoMarshalInterface, Is it recommended to use it ? if yes, then when I use LPSTREAM, I understand it should be moved to the other process and it would use CoUnMarshalInterface. How do you recommend to send this LPSTREAM ?

thanks a lot.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Where can I find the FoxPro ODBC Download version 1.0 6 39
SAPE.heur.AE935 Visual Studio 3 48
SignTool Error with Windows 10 5 150
VS2015 Redefinition errors 4 52
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question