Visual Basic Concepts
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.
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.
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 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.
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 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
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.
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
The only reason to make an executable at this point is to help your test project keep its reference to the component project.
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.