PRB: Visual Basic Replaces Missing Controls with PictureBoxes

Last reviewed: April 30, 1997
Article ID: Q167707
The information in this article applies to:
  • Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, version 5.0

SYMPTOMS

If a Visual Basic project uses a custom control (.OCX) whose CLSID has changed since the project was last opened, the following message will be displayed when opening the project:

   '<Path To OCX>' could not be loaded-Continue Loading Project?

After choosing "Yes," a second message will occur two times:

   "Errors during load. Refer to <Path To LOG File> for details"

Once the project is opened, all occurrences of the custom control have been replaced with PictureBox controls.

CAUSE

When Visual Basic attempts to load a custom control, each control is verified by its CLSID. If the CLSID stored with the project differs from the CLSID of the custom control, Visual Basic cannot load the control. In an attempt to maintain as many properties as possible, Visual Basic replaces the missing control with a PictureBox control. The code associated with the missing control is retained.

A CLSID of a custom control changes when any of the following conditions are true:

  • The custom control project's Version Compatibility setting is set to "No Compatibility." When no compatibility is set, a new CLSID is generated for a custom control every time it is compiled.
  • The custom control project's Version Compatibility setting is set to "Project Compatibility" or "Binary Compatibility," and the control's interface has been modified in such a way that compatibility could not be maintained. This will primarily occur if a Property or Method definition has changed.
  • A control is overwritten and the newer version has a different CLSID.

For more information about project compatibility, refer to the REFERENCES section below.

RESOLUTION

   WARNING: ANY USE BY YOU OF THE FOLLOWING STEPS PROVIDED IN THIS
   ARTICLE IS AT YOUR OWN RISK. Microsoft provides these steps "as is"
   without warranty of any kind, either express or implied, including
   but not limited to the implied warranties of merchantability and/or
   fitness for a particular purpose.

The CLSID of each custom control is saved in the project file (.VBP). The VBP file may be opened with Notepad or any text editor. If you know the new CLSID for the new version of the custom control, the VBP file can be modified to reflect this change in CLSIDs.

NOTE: Version compatibility in custom controls is used to ensure that your new version of a custom control will not break backward compatibility with applications that may be using older versions of your custom control. Following the example below to modify the project file with the new CLSID could result in unexpected errors in your application.

For example, if your custom control, named Custom.OCX, appears in your project, a line in the VBP file could read as follows:

   Object={B0784T02-A67Y-11E0-8840-00DD00F7B36C}#1.0#0; Custom.Ocx

You can modify the CLSID in the above line,

   {B0784T02-A67Y-11E0-8840-00DD00F7B36C}

with the new CLSID of the Custom.Ocx. Saving the VBP file and reopening the project with Visual Basic should solve the problem.

To obtain the new CLSID of your custom control, you may need to search the system registry or use a tool such as OLE2VIEW.EXE that can provide such information. The utility, OLE2VIEW.EXE, can be downloaded from the Microsoft Internet site at http://www.microsoft.com. To find the download file, search for "OLE2VIEW."

STATUS

This behavior is by design.

REFERENCES

For additional information, see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q161137
   TITLE     : HOWTO: Use Project and Binary Compatibility

See also the following section in the Visual Basic 5.0 Books Online:

Visual Basic 5.0 Components Guide, Chapter 7, "Debugging, Testing, and Deploying Components"


Keywords : kbenv kbtshoot kbui kbusage vb5all vb5howto VBKBAX VBKBComp VBKBCtrl VBKBDesignTime VBKBEnv VBKBVB kbprb
Version : 5.0
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.