Share via


Visual Basic Concepts

Debugging In-Process Components

This topic describes debugging procedures for most objects provided by in-process components. ActiveX documents, however, cannot be debugged as described here. See "Building ActiveX Documents."

To debug an in-process component

  1. Set breakpoints and watch expressions as needed in your class module or UserControl code.

  2. Run the project group by pressing CTRL+F5 or clicking Start With Full Compile on the Run menu.

    The in-process component will compile, but Sub Main will not run until the first object is created in response to a client request.

    While debugging, you can step from the test project directly into code in the component project.

  3. When you’re finished with the debugging session, click the Close button on test project’s main window to return to design mode.

    Important   Closing the test project by clicking the End button will cause all projects to close. Objects in the component will not receive Terminate events. Shutting down in this fashion will not correctly test the shutdown behavior of your component.

Start With Full Compile

You may find it more convenient to start the project group 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.

The default in Visual Basic is to compile code on demand. This means that there may be code in your component which is not compiled until the client calls it. Some compile errors cannot be fixed without returning to design mode, which means returning the whole project group to design mode.

Note   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.

Shutting Down an In-Process Component

In-process components will not unload while running in the development environment, even if all references to objects are released by the test project, and all other component shutdown conditions are met. The only way to test DLL unloading behavior is with the compiled component.

For More Information   "Using Break on Error in Components" explains how to use the Error Trapping options with component projects. ActiveX control projects must be debugged while the client is in design mode, as well as run mode. See "Debugging Controls" in "Building ActiveX Controls." ActiveX Documents cannot be debugged without a browser or other active document container. See "Building ActiveX Documents." See "Testing and Debugging ActiveX Components" for a list of topics related to testing and debugging.