Debug & Release version of OCX incompatible "Variable uses an Automation type not supported in Visual Basic"

3

I have a legacy OCX control built in VS2010 and used in a VB6 ActiveX EXE. When I register the debug version of the OCX and try to build it with VB6 I get the error AutoTypeNotSupportedInVB

If I register the Release version then the VB ActiveX EXE container compiles and runs. I've done online search for this error but the results are not very informative. It's not really clear if the error means it can't find the OCX type at all or if there's a type within the OCX interface that VB doesn't support. The error points to the first attempted use of the OCX object in the VB source code.

170 m_SignCaptureForm.SigPlus1.TabletComTest = False

Where SigPlus1 is the OCX object. Looking at the TypeInfo from OLE/COM Object Viewer the only differences I see between the Debug and Release are that all the BOOL return types are defined as char in the Debug version and as VARIANT_BOOL in the Release version.

========OLE/COM Object Viewer TypeInfo for Debug ========

      char TabletLCDMode;
      [id(0x00000010)            
]

=========OLE/COM Object Viewer TypeInfo for Release ========

      VARIANT_BOOL TabletLCDMode;
      [id(0x00000010)            
]

There's nothing in the OCX source code that I can see that would affect these declarations to be different in Debug vs Release. What I am asking is why I'm getting this error and if the cause is the difference in BOOL types whats the remedy for that?

ocx.h:    afx_msg BOOL GetTabletLCDMode();
ocx.cpp:  DISP_PROPERTY_EX(CSigPlusCtrl, "TabletLCDMode", GetTabletLCDMode, SetTabletLCDMode, VT_BOOL)
c++
visual-studio
vb6
ole
ocx
asked on Stack Overflow Mar 21, 2018 by JonN

1 Answer

3

Following @A. A suggestion to examine the property settings for the OCX projects ODL file (SigPlus.odl) I found the solution.

There were differences in the Release vs Debug settings when looking at the Properties for the SigPlus.odl file. To access ODL properties right click on the .ODL file in the source files in Solution Explorer. The setting that was making the Debug build declare bools as char was the MkTypeLib Compatible option. The debug build had this set to No and the Release had it set to Yes. Once I changed the debug build to MkTypeLib Compatible:Yes then the TypeInfo from OLE/COM Object Viewer showed the bools as VARIANT_BOOL just like the Release build and the VB ActiveX EXE container now builds successfully.

enter image description here enter image description here

answered on Stack Overflow Mar 22, 2018 by JonN

User contributions licensed under CC BY-SA 3.0