Visual Basic Concepts
This topic describes explains how to set up test projects to exercise most of the objects out-of-process components can provide. ActiveX documents, however, cannot be tested as described here. See "Building ActiveX Documents."
To create a test project for an out-of-process component
Important The reason you create this executable is to help your test project keep its reference to the component project. The executable is not required for debugging.
Use the ActiveX Component setting when testing your component with a client test program. If your component can also function as a standalone desktop application, use the Standalone setting to test that mode of operation, as described in "Debugging Out-of-Process Components."
Important Your component project must be in run mode! When you run your component in the development environment, Visual Basic switches its Windows registry entries from the executable (created in step 1) to the project, and switches them back when you return to design mode. You cannot add a reference to the component project unless it’s in run mode; a reference to the executable will not allow you to debug the component project in the development environment.
Important Always start your component project by pressing CTRL+F5, or by clicking Start With Full Compile on the Run menu, so that all compilation errors are resolved before your component begins supplying objects to your test application. Compiling component code on demand (the default) can lead to situations in which you have to shut down the component, leaving the test program holding invalid object references. (To disable demand compilation, select Options from the Tools menu, select the General tab of the Options dialog box, and clear Compile On Demand. This affects the current session as well as future instances of Visual Basic.)
Note As described in "How to Test ActiveX Components," you must use an ActiveX Exe project as your test project if your component implements asynchronous call-backs.
If your component does not appear in the References dialog box, switch back to the component project and make sure it’s running. If the component project does not stay in run mode when you press CTRL+F5, click <Project> Properties on the Project menu, to open the Project Properties dialog box. Select the Component tab, and make sure that ActiveX Component is selected in the Start Mode box.
If your component is running, but does not appear in the References dialog of your test project, stop the component and make sure at least one of its class modules has its Instancing property set to a value other than Private or PublicNotCreatable.
See "Programming with Components" in the Visual Basic Programmer’s Guide for more information on referencing other applications’ objects from within a client application.
Important Unless you recompile the executable in step 1 each time you make changes to code in your component project, you can only make changes to the test project while the component project is in run mode.
When the component project is not in run mode, the test project doesn’t have access to its type library, and will fall back on the type library in the compiled executable you created in Step 1.
The executable created in step 1 prevents the test project from losing its reference to the component project, but does not provide access to the features you’ve added since creating the executable.
You can use the Object Browser in the test project to verify that the public classes, methods, and properties of your component are available. In the test project, the Object Browser will show only the public members.
For More Information "How to Debug Out-of-Process Components" describes debugging techniques. ActiveX Documents cannot be debugged without a browser or other active document container. See "Building ActiveX Documents." "Project Compatibility: Avoiding MISSING References" describes the Project Compatibility option, and explains how to restore missing references.