KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q149565: PRB: Unable to Load Control from C:\Path\File.ocx

Article: Q149565
Product(s): Microsoft C Compiler
Version(s): winnt:
Operating System(s): 
Keyword(s): kbcode kbole kbCtrl kbMFC kbVBp kbGrpDSVB kbprb
Last Modified: 30-JUL-2001

-------------------------------------------------------------------------------
The information in this article applies to:

- The Microsoft Foundation Classes (MFC), used with:
   - Microsoft OLE Control Developer's Kit (CDK) 
   - Microsoft Visual Basic Professional Edition, 32-bit, for Windows, version 4.0 
   - Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows, version 4.0 
-------------------------------------------------------------------------------

SYMPTOMS
========

When you try to load an OLE Control generated by using ControlWizard into a
Visual Basic 4.0 form in Visual Basic by on the Tools menu, clicking Custom
Controls and then clicking the Browse button, the following error message
appears:

  "Unable to load control from: 'x:\path\file.ocx'"

CAUSE
=====

Visual Basic checks an OLE control to see whether it supports self- registration
by searching for the presence of an OLESelfRegister entry in the StringFileInfo
section of the control's version information resource. ControlWizard-generated
OLE controls do not provide the entry by default.

RESOLUTION
==========

Modify the OLE Control to indicate its support for the self-registration
feature. This can be achieved by including the OLESelfRegister entry with an
empty value in the StringFileInfo section of the control's version resource. The
following steps explain the process in detail.

Step-by-Step Procedure
----------------------

1. Open the .rc file of the OLE Control as a Text file.

2. Find the StringFileInfo block under Version information.

3. Add the following line to the existing list of VALUE statements:

     VALUE "OLESelfRegister", "\0"

4. Build the OLE Control. Now you can load the OLE Control (.ocx file) by
  clicking Custom Controls on the Tools menu and clicking the Browse button.

STATUS
======

This behavior is by design.

MORE INFORMATION
================

A COM server typically indicates its support for self-registration by including
the OLESelfRegister entry with an empty value in the StringFileInfo of its
version resource. This entry is considered optional because the actual
self-registration mechanisms do not depend on its presence. This information
simply allows a client application to avoid loading a DLL (that is, an
in-process server or OLE control) or launching an .exe (that is, a local server)
for no gain.

The only requirement for an OCX/DLL to support the self-registration mechanism is
to provide the entry points DllRegisterServer and DllUnregisterServer and export
them. ControlWizard-generated OLE controls provide these two entry points and
export them, though they do not indicate their self-registration support by not
including the OLESelfRegister entry by default.

REFERENCES
==========

Please refer to Chapter 5 of Inside OLE, Second Edition, for more information on
self-registration.

Additional query words: 2.00 2.10 2.20 4.00 4.10 load failure

======================================================================
Keywords          : kbcode kbole kbCtrl kbMFC kbVBp kbGrpDSVB kbprb 
Technology        : kbAudDeveloper kbMFC
Version           : winnt:
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.

Copyright Microsoft Corporation 1986-2002.