Share via


Visual Basic Concepts

Creating and Testing the Coffee Executable

Once an out-of-process component project is tested and debugged in the development environment, you can compile and test the .exe file.

An ActiveX component is compiled the same way any Visual Basic project is compiled — by choosing Make from the File menu. The .exe file includes a type library that describes your objects and allows them to be browsed. Visual Basic automatically registers the component in your Windows registry when you make the executable file.

Note   When you distribute your application as part of an integrated solution, registration is done during setup. If you use the Visual Basic Package and Deployment Wizard, registration of your component will be included in the setup process automatically. This is discussed in "Deploying Components" in "Debugging, Testing, and Deploying Components."

For More Information*   The Package and Deployment Wizard is described in "Distributing Your Applications" in the *Visual Basic Programmer’s Guide.

Note   This topic is part of a series that walks you through creating a sample ActiveX EXE. It begins with the topic Creating an ActiveX EXE Component.

To compile and test the Coffee executable

  1. If the Coffee project is still in run mode, click the End button to return to design mode.

  2. On the File menu, click Make Coffee.exe to open the Make Project dialog box. Click OK to build the .exe file.

  3. Switch to the CoffeeWatch project. On the Project menu, click References to open the References dialog box. Remove the check mark from the Coffee Monitor Component entry for the .vbp file, and check the entry for the .exe file.

    You can tell the entries apart by observing the Location in the information panel at the bottom of the dialog box.

  4. On the File menu, click Make CoffeeWatch.exe to open the Make Project dialog box. Click OK to build the .exe file.

  5. (Optional) Press F5 to run CoffeeWatch using the compiled Coffee executable.

  6. Use the Explorer (or the Run box, on the Start menu) to start one or more instances of CoffeeWatch.exe.

    Notice that all the instances of CoffeeWatch appear to get their CoffeeReady events at the same time. In reality, the clients get their events one after the other — a single thread of execution traces through all of the event handlers. You can see this demonstrated in the sample applications for this chapter.

    Important   When multiple objects are handling events from one event source — a scenario referred to as multicasting — the order in which they get events is undefined, and implementation dependent. You should never write code that depends on any particular order of event arrival among the multicasting clients.

    Events are anonymous — that is, the object that raises the event doesn’t know how many objects (if any) are handling the event.

To switch back to using Coffee.vbp, you can use the References dialog box to clear the entry for the .exe file and check the entry for the .vbp file instead.

Note   You can compile CoffeeWatch.exe using either the compiled Coffee.exe, or Coffee.vbp. The latter is useful for debugging with multiple clients. The CoffeeWatch executable will be compiled using whichever entry is currently checked in the References dialog box.

For More Information   You can read more about test projects and debugging techniques in "Debugging, Testing, and Deploying Components."

Step by Step

This topic is part of a series that walks you through creating a sample ActiveX EXE.

To See
Go to the next step ActiveX EXE Component Creation Summary
Start from the beginning Creating an ActiveX EXE Component