Microsoft KB Archive/237175

= FIX: VB IDE Improperly Changes Registry Entries of ATL Object Interface When Generating OCA File =

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:

http://msdn2.microsoft.com/en-us/vstudio/Aa718353.aspx



Create an ATL DLL
 Start Microsoft Visual C++, and, on the File menu, choose New. Choose ATL COM AppWizard and type SimpleATLControl as the project name. Click the Finish button. On the Insert menu, select New ATL Object. Click Simple Object, and then click Next. Type SimpleATLObj in the Short Name box, and then click OK.</li> Click the Insert menu again, and then click New ATL Object.</li> Choose the Controls category and click on Full Control.</li> Type SimpleATLCtl in the Short Name box and click OK.</li> Save the project.</li> From the Build menu, choose Build SimpleATLControl.dll, and wait until the build is finished.</li> Open a Command Prompt window and browse to the SimpleATLControl project folder.</li>  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. </li>  Register SimpleATLControlps.dll by using the regsvr32 utility with a command line, such as: <pre class="fixed_text">regsvr32.exe \SimpleATLControlps.dll </li> Run the OleView utility, expand Interfaces, and look at these two interfaces: <ul> ISimpleATLObj</li> ISimpleATLCtl</li></ul>

</li> You may see the following: <ul> The Typelib key for both interfaces refers to SimpleATLControl.dll.</li> The ProxyStubClsid32 key for both interfaces points to PSFactoryBuffer class in SimpleATLControlps.dll.</li></ul> </li></ol>

Create a Visual Basic Client
<ol> Start a Standard EXE project in Visual Basic. Form1 is created by default.</li> <li>From the Project menu, select Components, select SimpleATLControl 1.0 Type Library, and then click OK.</li> <li>Locate the OleView utility, and, from the View menu, select Refresh.</li> <li>Look at the following two interfaces again:

<ul> <li>ISimpleATLObj</li> <li>ISimpleATLCtl</li></ul>

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.</li> <li>However, if you look at the interface ISimpleATLObj, you find two changes: <ul> <li>The Typelib key is changed to SimpleATLControl.oca.</li> <li>The ProxyStubClsid32 key is changed to PSOAInterface in oleaut32.dll.</li></ul>

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.</li></ol>

Additional query words: sp4

Keywords: kbbug kbdll kbfix kbide kbvs600sp4fix kbvs600sp5fix KB237175

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.