Visual Basic Concepts

Compiling and Testing the ThingDemo DLL

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

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

An ActiveX component is compiled the same way any Visual Basic project is compiled — by choosing Make from the File menu. The .dll file includes a type library that describes your objects and allows them to be browsed.

Visual Basic makes it easy to add the necessary lines to the Windows Registry. You don’t have to write any code, and you don’t have to understand the format of registry entries. When you make the executable file, Visual Basic automatically registers it on your computer.

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.

To compile and test the OLE DLL executable

  1. If the TestThing project is still in run mode, click the Close button on Form1 to return to design mode.

  2. In the Project Explorer window, click ThingDemo to select the project.

  3. On the File menu, click Make ThingDemo.dll to open the Make Project dialog box. Click OK to build the .dll file.

  4. On the File menu, click Remove Project to remove ThingDemo from the project group, so that Visual Basic will use the compiled binary component (.dll file) instead of the project.

    Visual Basic displays a warning message, because the TestThing project contains a reference to ThingDemo. Click Yes to remove ThingDemo anyway.

    When you remove ThingDemo from the project group, Visual Basic looks for ThingDemo.dll in the Windows Registry. If the .dll file exists, Visual Basic automatically updates the reference you set in "Creating the TestThing Project."

    To switch back to using the project instead of the binary component, you can click Add Project on the File menu, and add the ThingDemo project back to the project group.

  5. Press F5 to run TestThing using the .dll file.

You can compile TestThing.exe, and run it with the .dll. You can also test the compiled ThingDemo.dll from other applications.

To use ThingDemo.dll in another copy of Visual Basic

  1. Open a new instance of Visual Basic. In the NewProject dialog box, double-click the EXE Project icon to open a new EXE project.

  2. On the Project menu, click References to open the References dialog box. Check ThingDemo ActiveX DLL, and then click OK.

    You can now add code to create Thing and Dialogs objects and invoke their properties and methods.

  3. Press F5 to run the project.

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

To See
Go to the next step Circular References and Component Shutdown
Start from the beginning Creating an ActiveX DLL.