Blog from September, 2014

Dealing with Variants in COM

Many COM APIs make extensive use of Variants and this can degrade translation quality.   In fact, I was recently working on upgrading a commercial VB6 application to C# and I encountered the following error in the C# build log:

ERRNUM: CS0029: Cannot implicitly convert type 'byte' to 'byte[]'
NETSRC: ... frmAttachWindow.cs@287
bbuf = Convert.ToByte(vbuf);
ERRNUM: CS0029: Cannot implicitly convert type 'byte[]' to 'object[]'
NETSRC: ... frmAttachWindow.cs@291
vbuf = sendbuf;


Looking at the VB6 code I find this:

Dim vbuf As Variant
Dim bbuf() As Byte

and later this

vbuf = frmMain.MSComm.Input

I suspect  frmMain.MSComm.Input is a member of an MSCOMM control.  I look up the definition of this member in the generated interface description file (IDF) for MSCOMM and I find this:

   <class id="IMSComm" parent="IDispatch" default="_CommPort">
      <property id="Output" type="Variant" status="InOut"/>
      <property id="Input" type="Variant" status="InOut"/>

And change it to this

   <class id="IMSComm" parent="IDispatch" default="_CommPort">
      <property id="Output" type="Byte[]" status="InOut"/>
      <property id="Input" type="Byte[]" status="InOut"/>

I save the updated IDF in my usr folder so it will take precedence over the generated one.

I take a snapshot of the last translation, and I rerun the translation using the new IDF.

Comparing the snapshot (left) to the new results (right) shows the dramatic improvements – and the orginal C# build errors are gone.

gmStudio technology allows a migration team to modify the type information for your COM APIs. This will result in cleaner more correct translations.  Modifying type information can also be used to direct the tool to replace COM components with .NET classes.  See Custom COM Replacement for additional information.

09/15/2014 Major Release


  • Updated translation engine (V20.02B9)
  • Improved translation accuracy and correctness
  • Adding CheckMultipleTypes option for alternate processing of variants with multiple types
  • Improve logic for detecting event handlers from COM interface information
  • Improve handling of enums used in logical and mathematical expressions


  • Improve handling of external tool for report file viewing
  • Improve handling of external tool for file comparison viewing
  • Improve layout and content on Check for Updates form
  • Update toolbar button tooltips
  • Additional improvements in Registration and License Support
  • Correct logic that preserves user preferences in gmStudio.cfg file during product updates
  • Correct metalang script processing to read appropriate IDF folder
09/08/2014 public release


  • [Chg] Display appropriate icons on all message boxes
  • [Chg] Display status bar in gmStudio Plugin
  • [Fix] Prevent exception when cannot find gmAdmin (issue for plugin)
  • [Fix] Prevent exception upgrading application config file in AppData folder (Win8)

Known Issues

  • gmStudio Plugin hangs VS2013 on first run.
09/05/2014 public release


  • [Add] Added UI Themes based on installed Visual Studio Themes
  • [Add] Added Automatic Product Update Support
  • [Chg] Improved Product Registration and License Support
  • [Chg] Improved handling of exceptions during IDL generation
  • [Chg] Modify toolBar Help button to display Help menu items (for VS Extension)
  • [Chg] Allow project-specific environment setup script for starting Visual Studio/MSBuild
  • [Fix] Correct error when trying to run builds when Visua lStudio/Msbuild is not installed

gmStudio Plugin

  • [Chg] Updated for VS2013 (beta)


  • [Chg] Improved support for repair/upgrade through windows installer package (MSI file).