Solved

Problem with multiple Instances of ActiveX Server

Posted on 1998-12-07
2
175 Views
Last Modified: 2008-02-26
I have two executables.  Executable A has an User Interface and at the same time exposes an object to other applications.  A is configured as a standalone ActiveX exe and the class in A is configured to be MULTIUSE.  App B uses the object exposed by A.  App B also has an User Interface.

I use the two apps in the following way. I start App A first, then shell App B (with the Shell function)  from within App A. I use app A as a container for app B (A becomes the parent window for B). Then in App B I use the "set objxx as New clsAppA" statement to create an instance of the object and use it.  

The problem is...when I do this from the debug environment (running app A in IDE and shelling B as an Exe), I end up with two instances of App A.  It appears that when App B creates the object and uses it, this action  generates another instance of the App A server.  I thought that the "multiuse" selection on the class should prevent this from happening.  If I run the exe version of App A (running the compiled App A ) then I don't get the extra instance.  What's going on here and how do I fix it?

Any help would be appreciated
0
Comment
Question by:debbyt
2 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 1448666
Multiuse will mean what you expect only for ActiveX DLL project type. E.g. Loading("mydll.dll") will only increment its internal usage-counter. There will be only 1 dll in memory.

>I thought that the "multiuse" selection on the class should prevent ...
If it is EXE, of course you will be able to start many instances.

>how do I fix it?
What?
0
 
LVL 3

Accepted Solution

by:
covington earned 200 total points
ID: 1448667
MultiUse does not mean that your EXE server will only provide one instance of the object. It means that one instance of the running EXE will be used to provide multiple objects. If you set the property to SingleUse, then every 'Set xxx = new MyEXEServer' will launch a new copy of the EXE.

If you have it set as multiuse, but you want several instances of your class to be able to talk to each other, use global variables declared in regular modules. All classes will access the same copy of these variables.

It sounds like when you run A (IDE) and then launch B (EXE), and then B (EXE) launches A, B launches the compiled version of A to provide the object. Your description of 'two instances of A' is a little confusing, since you are always getting two instances of the class - just not two EXEs running.

If B is launching a compiled version of A when A is originally started from the IDE, check your project compatibility settings on A. It should be set to binary compatibility for the task that you want to accomplish. Also, after you have set this, check the references in B. The references in project B should be pointing to the compiled version of A. Now start A, but don't execute any code in B yet. Check the references in B. It should have automatically switched to the *.vbp of A. If this isn't happening, then binary compatibility isn't set up correctly.

Good luck. You are attempting to create crcular COM references. Although it's technically possible, it can be a real headache to develop & deploy. You'll really have trouble anytime you change the interface of A.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now