KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q237175: FIX: VB IDE Improperly Changes the Registry of ATL Objects

Article: Q237175
Product(s): Microsoft Visual Basic for Windows
Version(s): WINDOWS:5.0,6.0; winnt:6.0
Operating System(s): 
Keyword(s): kbActiveX kbATL kbDLL kbide kbVBp kbVBp500bug kbVBp600bug kbVC600 kbGrpDSVB kbDSupport
Last Modified: 28-JUL-2001

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

- Microsoft Visual Basic Learning Edition for Windows, versions 5.0, 6.0 
- Microsoft Visual Basic Professional Edition for Windows, versions 5.0, 6.0 
- Microsoft Visual Basic Enterprise Edition for Windows, versions 5.0, 6.0 
- Microsoft Visual C++, 32-bit Professional Edition, version 6.0 
-------------------------------------------------------------------------------

SYMPTOMS
========

If you have an Active Template Library (ATL) DLL that includes a control and an
ATL object and you create a custom marshalling DLL for both the control and the
object, then when you reference this ATL DLL as a component in a Visual Basic
project, the Visual Basic integrated development environment (IDE) improperly
changes the Registry entries for the interface of the ATL object. The Registry
entries that are changed are the Typelib and the ProxyStubClsid32 keys of the
interface.

CAUSE
=====

When a control in the Visual Basic IDE is referenced, it generates an .oca file.
The .oca file creates a new interface ID for the control and registers the new
interface ID in the Registry. However, at the same time, the Visual Basic IDE
improperly changes the Registry entries for the interface of the ATL object,
which is in the same DLL as the control.

STATUS
======

Microsoft has confirmed this to be a bug in the Microsoft products listed at the
beginning of this article. This bug was corrected in the latest service pack for
Visual Studio 6.0.

For additional information about Visual Studio service packs, click the article
numbers below to view the articles in the Microsoft Knowledge Base:

  Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

  Q194295 HOWTO: Tell That a Visual Studio Service Pack Is Installed

You can download the latest Visual Studio service pack from the following
Microsoft Web site:

  Visual Studio Product Updates
  (http://msdn.microsoft.com/vstudio/downloads/updates.asp)

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

Steps to Reproduce Behavior
---------------------------

Create an ATL DLL:

1. Start Microsoft Visual C++, and, on the File menu, choose New.

2. Choose ATL COM AppWizard and type "SimpleATLControl" (without the quotation
  marks) as the project name.

3. Click the Finish button.

4. On the Insert menu, select New ATL Object.

5. Click Simple Object, and then click Next.

6. Type "SimpleATLObj" (without the quotation marks) in the Short Name box, and
  then click OK.

7. Click the Insert menu again, and then click New ATL Object.

8. Choose the Controls category and click on Full Control.

9. Type "SimpleATLCtl" (without the quotation marks) in the Short Name box and
  click OK.

10. Save the project.

11. From the Build menu, choose Build SimpleATLControl.dll, and wait until the
  build is finished.

12. Open a Command Prompt window and browse to the SimpleATLControl project
  folder.

13. Type the following command and press Return:

  NMake SimpleATLControlps.mk /all

  Wait until the build is finished, and note that the SimpleATLControlps.dll is
  generated.

  NOTE: If this command line generates an error, you may need to run the
  Vcvars32.bat file from the Visual C++ BIN directory to set the compiler
  environment variables.

14. Register SimpleATLControlps.dll by using the regsvr32 utility with a command
  line, such as:

regsvr32.exe <path>\SimpleATLControlps.dll

15. Run the OleView utility, expand Interfaces, and look at these two
  interfaces:

   - ISimpleATLObj
   - ISimpleATLCtl

16. You may see the following:

   - The Typelib key for both interfaces refers to SimpleATLControl.dll.
   - The ProxyStubClsid32 key for both interfaces points to PSFactoryBuffer
     class in SimpleATLControlps.dll.

Create a Visual Basic Client:

1. Start a Standard EXE project in Visual Basic. Form1 is created by default.

2. From the Project menu, select Components, select SimpleATLControl 1.0 Type
  Library, and then click OK.

3. Locate the OleView utility, and, from the View menu, select Refresh.

4. Look at the following two interfaces again:

   - ISimpleATLObj
   - ISimpleATLCtl

  Note that another interface with the same name (ISimpleATLCtl) is generated by
  the Visual Basic IDE and that the Typelib key points to SimpleATLControl.oca.

5. However, if you look at the interface ISimpleATLObj, you find two changes:

   - The Typelib key is changed to SimpleATLControl.oca.
   - The ProxyStubClsid32 key is changed to PSOAInterface in oleaut32.dll.

These two changes are not proper because the Visual Basic IDE does not generate a
new interface ID for ISimpleATLObj, but it changes its Typelib and
ProxyStubClsid32 Registry entries. These changes would break existing programs
that are using the custom marshalling DLL SimpleATLControlps.dll.

Additional query words: sp4

======================================================================
Keywords          : kbActiveX kbATL kbDLL kbide kbVBp kbVBp500bug kbVBp600bug kbVC600 kbGrpDSVB kbDSupport kbVS600sp4fix kbVS600sp5fix 
Technology        : kbVCsearch kbVBSearch kbAudDeveloper kbZNotKeyword6 kbZNotKeyword2 kbVB500Search kbVB600Search kbVB500 kbVB600 kbVC600 kbVC32bitSearch
Version           : WINDOWS:5.0,6.0; winnt:6.0
Issue type        : kbbug
Solution Type     : kbfix

=============================================================================

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.