Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ActiveX reference count

Posted on 1998-01-21
4
293 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with ASP.NET C# CodeBehind for a Button and two text box controls 8 20
Post a good COM tutorial 1 60
Is IHttpActionResult a promise pattern? 2 68
PL SQL Developer 7 52
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

792 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