Knowledge Base

BUG: Enumerated Type Parameters Break Binary Compatibility

Article ID: 184286

Article Last Modified on 3/11/2005


APPLIES TO


This article was previously published under Q184286

SYMPTOMS

When developing an ActiveX DLL or ActiveX EXE, Visual Basic might erroneously report that you have broken Binary Compatibility when you try to compile your project. This could happen even if you have not changed a single line of code in your project.

CAUSE

The most common cause for this problem is a known bug, in which ENUMS is used as a function parameter.

For example, if you have the following line of code in an ActiveX DLL:
   Public Property Get MyProp(NewValue As MyEnum) as clsMyClass
				
When you try to compile this code with Binary Compatibility turned on, you might receive the following error:
MyProp in the MyClass Class Module has arguments and a return type that is incompatible with a similar declaration in version component.
When you receive the error, you can click the "Show Declaration" command button (which shows you the version-compatible declaration of the function and the declaraton in the current project). Note that the two declarations are exactly the same, even though Visual Basic gives the error.

Service Pack 3 for Microsoft Visual Studio addresses this issue, but does not always fix the bug.

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

171819 FIX: Invalid Enum Value Causes Incompatible Binary Compatible

RESOLUTION

The following are three suggested workarounds for this bug:

Steps to Implement the Type Library Workaround

The Binary Compatibility bug usually occurs with very large projects, and late in development. However, if you do start receiving broken Binary Compatibility error messages, you should do the following:
  1. Copy all ENUM declarations into a new ActiveX DLL.
  2. Go to the select Project Properties from the Project menu and select the Component tab.
  3. Select the Remote Server Files option. This will make sure that a TLB file is generated when the ActiveX DLL is compiled. A TLB file contains the Type Library for the ActiveX Component it is associated with.
  4. Save the ActiveX DLL for future use.
  5. Compile the ActiveX DLL
  6. Unregister the ActiveX DLL you just compiled by doing the following, select Run from the Windows Start menu and type in the following command:

    <Path to RegSvr32>\Regsvr32.Exe /u <Path to Project>\ProjectName.DLL
  7. Load up the actual ActiveX Server that is raising the broken Binary Compatibility error message.
  8. Make sure all the ENUM declarations have been removed.
  9. Select References from the Project menu.
  10. From References, select the "Browse" button.
  11. Locate and select your newly created TLB file.
  12. Compile your ActiveX server. The error message will no longer appear.
You can also bypass unregistering the ActiveX DLL which contains the ENUM declares, and reference the DLL itself instead of the TLB file.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

Additional query words: kbDSupport kbdss vb6test

Keywords: kbbug kbpending KB184286