Solved

Problem with multiple Instances of ActiveX Server

Posted on 1998-12-07
2
186 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

713 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