Visual Basic Concepts
Testing and Debugging ActiveX Components
Visual Basic provides two different component debugging scenarios. For in-process components, you can load a test project (Standard Exe or ActiveX Exe) and one or more component projects into the development environment as a project group. You can run all the projects in the group together, and step directly from test project code into in-process component code.
Out-of-process components can be debugged using two instances of the development environment. One instance of Visual Basic runs the test project, while the second runs the component project. You can step directly from test project code into component code, and each instance of Visual Basic has its own set of breakpoints and watches.
Combinations of these scenarios are possible. You can debug an application that uses both in-process and out-of-process components, as shown in Figure 7.1.
Figure 7.1 Debugging in-process and out-of-process components
When an ActiveX Exe project is in run mode, like MyComponent in Figure 7.1, the client application (MyApp) can create objects and access their properties and methods. Each out-of-process component a client uses must be in its own instance of the development environment. The client application and all of its in-process components — DLLs and OCXs — can run together in a single instance of the development environment.
The following topics explain the basics of debugging and testing components.
How to Test ActiveX Components By definition, a component is software used by other programs, so it cannot test itself. This topic covers testing requirements and things to watch out for.
Creating a Test Project for an In-Process Component Setting references and options for testing in a multiple-project environment.
Creating a Test Project for an Out-of-Process Component Starting a second instance of the development environment, and setting the necessary references and options.
Project Compatibility: Avoiding MISSING References While developing your component, you will sometimes find it necessary to make changes that break the link between your test program and your component project.
Debugging Out-of-Process Components Debugging techniques for working with two instances of the Visual Basic development environment.
Debugging In-Process Components Debugging multiple projects in a single instance of the development environment.
Using Break on Error in Components New keyboard shortcuts make it easier to debug components, especially those with class module code containing error handlers.
How to Test Compiled Components Switching between source projects and compiled components.
For More Information* There are special considerations for debugging and testing ActiveX control projects, and other project types that include private controls. See "Setting Up a New Control Project and Test Project" and "Debugging Controls" in "Building ActiveX Controls." Information specific to debugging and testing ActiveX Documents can be found in "Building ActiveX Documents." The fundamentals of debugging are covered in "Debugging Your Code and Handling Errors" in the *Visual Basic Programmer’s Guide.