Solved

Problem with multiple Instances of ActiveX Server

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 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

14 Experts available now in Live!

Get 1:1 Help Now