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:
- Copy all ENUM declarations into a new ActiveX DLL.
- Go to the select Project Properties from the Project menu and select
the Component tab.
- 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.
- Save the ActiveX DLL for future use.
- Compile the ActiveX DLL
- 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 - Load up the actual ActiveX Server that is raising the broken Binary
Compatibility error message.
- Make sure all the ENUM declarations have been removed.
- Select References from the Project menu.
- From References, select the "Browse" button.
- Locate and select your newly created TLB file.
- 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.