Solved

ActiveX reference count

Posted on 1998-01-21
4
311 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
[X]
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
  • 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

628 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