Using the Legacy OCX Controls with C# and VB.NET

 

Applications written in C# or VB.NET are able to use both the Normal or the Legacy version of the OCX controls. When converting an already written C# or VB.NET application from the normal OCX files to the legacy builds or vice versa, the following should be considered.

 

Applications written in VB.NET can be recompiled without modifications and are able to use both versions of the OCX files once compiled. You can use either the Long (64-bit) or Integer (32-bit) datatypes.

 

Applications written in C# require modifications in the source code to compile successfully with the legacy build of the OCX files. In C#, the long datatype is a 64-bit integer, and int is a 32-bit integer. When using the legacy build of the SDK, variables passed to the OCX functions or returned by the OCX functions must be modified from long to int. Once the C# application is compiled, the application is able to run, whether the normal or the legacy OCX files are registered.

 

E.g.:

 

Normal Document Imaging OCX call:

 

long hDib = BiTiff.LoadTiffIntoDIB(fileName, 0, false);

long hDibNew = BiDIB.RotateDIB90(hDib);

 

Document Imaging OCX call for legacy languages:

 

int hDib = BiTiff.LoadTiffIntoDIB(fileName, 0, false);

int hDibNew = BiDIB.RotateDIB90(hDib);

 

 

When a VB.NET or C# application that uses an OCX file is compiled, Visual Studio generates Interop and AxInterop DLLs for each used OCX file. (E.g.: Interop.BIDBLib.dll). Make sure the Interop/AxInterop files match the built EXE file. Always use the files that were generated when the EXE file was compiled, do not reuse the files from earlier builds.