Project Compatibility: Avoiding MISSING References

See Also

In the course of building, testing, and debugging components, you may occasionally see the following error message when you attempt to run your test project: "Connection to type library or object library for remote process has been lost. Press OK for dialog to remove reference."

There are two reasons for this error: Either the type library for your component project is not available, or the GUID of your component’s type library has changed, and therefore your test project can no longer locate it. See "Polymorphism, Interfaces, Type Libraries, and GUIDs," in "General Principles of Component Design," for information about GUIDs and type libraries.

The solution varies, depending on the setting of the Version Compatibility option in your component project. You can find the Version Compatibility option on the Component tab of the Project Properties dialog box, available from the Project menu.

If Your Component Is Using Project Compatibility

When you make your component project into an executable (.exe, .dll, or .ocx file) for the first time, as described in "Creating a Test Project for an Out-of-Process Component," Visual Basic automatically sets the Version Compatibility option to Project Compatibility and inserts the path to your made executable. This ensures that your test project and component project remain connected from one development session to the next.

If you’re using Project Compatibility for your component project, the solution to the error depends on whether you’re debugging the component in the development environment, or attempting to test the made executable.

If You’re Debugging the Component Project Out of Process

When you’re debugging an out-of-process component (ActiveX Exe projects) in a second instance of the development environment, the test project loses its connection when the component project is in design mode, because the component project’s type library is not available.

Run your component project. Switch back to the test project and press Esc to dismiss the error message. You can then run the test project.

Note   You may encounter this situation with an ActiveX DLL project if you’re debugging an in-process component in a separate instance of the development environment, for example when debugging an in-process component that provides ActiveX documents.

If the Component Project Is Running

If you’ve just made your component executable for the first time, or manually switched from No Compatibility to Project Compatibility — as described later in this topic — the GUID of your component’s type library will have changed, and the test project will be unable to locate it.

Click OK on the error message to open the References dialog box. You’ll see the word MISSING next to your component. Remove the check mark and click OK, to clear the missing reference. On the Project menu, click References to open the References dialog box again. Check your component and click OK.

If You’re Testing the Made Executable Component

In order to switch between the component project and the made executable component, you must make an up-to-date version of the executable, as described in "How to Test Compiled Components." If you haven’t done this, the type library GUIDs of the executable and the component project will not match, and the test project will not be able to find the executable.

Make the component executable. Switch back to the test project and press ESC to dismiss the error message. You can then run the test project.

If Your Component Project Is Using No Compatibility

If you for some reason you want to use the No Compatibility option for your project, you will have to refresh the reference each time you close your project group (in-process components) or projects (out-of-process components) and reopen them.

To refresh a test application’s reference to your component

  1. On the Project menu of your test project, click References to open the References dialog box.

  2. Locate the entry for your component, which will be marked MISSING. Clear the selection, and click OK.

    If there is no entry marked MISSING, locate the component project (the file name and path shown in the References dialog box must have the extension .vbp) and check it, then click OK. Skip to step 4.

    If your component project does not appear, click OK to close the dialog.

  3. Make sure your out-of-process component is running. If your component isn’t in run mode, there’s no type library for the test application to get a reference to.

  4. Open the References dialog box again. Locate the entry for your component project (.vbp file), and verify that it’s no longer marked MISSING. Check it and click the OK button.

  5. Press F5 to run the test application.

Setting the Project Compatibility Option

The easiest way to set Project Compatibility is to make your component executable (.exe, .dll, or .ocx) for the first time. As described earlier, Visual Basic automatically sets Project Compatibility the first time you make the executable.

If for some reason your project has been set to No Compatibility, you can manually change it to one of the other two Version Compatibility options. Binary Compatibility, described in "Version Compatibility," later in this chapter, is the option to use if you’re developing an enhanced version of an existing component.

The option you should use for all new development is Project Compatibility.

To set the Project Compatibility option

  1. On the File menu of your component project, click Make <project name> to create an executable file. If there’s an existing executable, overwrite it.

    The only reason to make an executable at this point is to help your test project keep its reference to the component project.

  2. On the Project menu of your component project, click <project> Properties to open the Project Properties dialog box.

  3. On the Component tab, click Project Compatibility in the Version Compatibility box.

  4. Type the name of your executable in the box at the bottom of the Version Compatibility box, or use the ellipsis button to browse for it, and then click OK.

Note   The Project Compatibility option actually has nothing whatever to do with the Binary Compatibility option (described in "Version Compatibility.")

For More Information   Type libraries and GUIDs are discussed in "Polymorphism, Interfaces, Type Libraries, and GUIDs," in "General Principles of Component Design." "Debugging Out-of-Process Components" explains important aspects of debugging, such as the fact that your component project must be in run mode when you edit your test project.