PRB: .Net Program that Calls Barcode ActiveX does not Run on 64-bit Windows

SYMPTOMS

A .Net program that calls Barcode ActiveX worked fine on 32-bit Windows. However, it does not start on Vista 64-bit, or throws an unhandled exception. The error code is REGDB_E_CLASSNOTREG.

The Barcode ActiveX control has been copied to the target machine and registered correctly.

CAUSE

By default, Visual Studio compiles .Net program under Any CPU setting, which generates x64 executable on a 64-bit PC and x86 executable on a 32-bit PC. However, Morovia Barcode ActiveX 3.x binary are x86 format only and can't be loaded into a x64 executable. Therefore, when running on x64 Windows, the .net run time throws an exception that complains that it can not locate Barcode ActiveX control.

RESOLUTION

When compiling programs that calls 32-bit DLLs, including COM objects, change the target CPU from Any CPU to x86 and rebuild the program.

To change the target CPU, perform the following steps (in Visual Studio 2005):

  1. Right click on the project and select Properties.

  2. click on Compile tab and click on Advanced Compile Options button.

  3. In the Target CPU combo box, change it to x86.

STATUS

This behavior is by design.

APPLIES TO

  • Morovia Barcode ActiveX 3.x

  • Microsoft Visual Studio 2005

  • Windows Vista 64-bit Business