Microsoft KB Archive/237175

From BetaArchive Wiki

Article ID: 237175

Article Last Modified on 8/7/2007



APPLIES TO

  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Professional Edition



This article was previously published under Q237175

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 that this is a bug in the Microsoft products that are 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 following article numbers to view the articles in the Microsoft Knowledge Base:

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

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


To download the latest Visual Studio service pack, visit the following Microsoft Web site:

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 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 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 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: kbbug kbdll kbfix kbide kbvs600sp4fix kbvs600sp5fix KB237175