Solved

Problem with multiple Instances of ActiveX Server

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

739 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