相互運用の概要

Microsoft は、ネイティブ コードと マネージ コードの相互運用の技術を提供しています。また、オプションの説明や戦略に関するアドバイスを含む優れたドキュメントを公開しています。

大まかに言うと、ネイティブ COBOL コードと マネージ コード (.NET COBOL またはその他の マネージ 言語) の間で呼び出しを行うための手法は 3 つあります。

ネイティブ COBOL と .NET COBOL の相互運用では、データ型の変換について心配する必要はありません。COBOL のコンパイル時にネイティブ型が認識されて、適切な .NET 型に変換されます。

ただし、ネイティブ COBOL が他の言語の マネージ コードと相互運用するには、その言語と互換性のあるデータ型を使用する必要があります。多くの場合、異なる言語の型同士には厳密な 1 対 1 の対応はないため、コードを操作して互換性を確保する必要があります。たとえば、整数 (PIC S9(9) comp-5 など) の場合は、C# と Java 両方の int に対応する、定義済みの binary-long 型を使用できます。

Micro Focus の COM サポート

COM is a feature of Microsoft Windows which enables one application to load and send messages to any application registered with the operating system as a COM Automation server.

Micro Focus COM support enables you to send messages to COM objects from COBOL programs and classes (where this COBOL is behaving as a COM client). You can also create COM objects, enabling you to manipulate a COBOL class through COM Automation.

The terminology used to describe COM components - servers, classes, clients, and objects - can be confusing. In this documentation, we use these terms as follows:

  • COM class - COBOL class that you write based on existing COBOL programs
  • COM server or COM Automation server - an application created using COM classes
  • COM client - any program that accesses a COM server application
  • COM object or component - an instance of a COM server application received by a client

COM objects are built using Microsoft's Component Object Model (COM). There are two main differences between COM and a language such as native OO COBOL:

  • COM does not support inheritance. When you write a new COM class, you can't inherit functionality from any of your existing COM or non-COM classes.
  • COM does not support class methods and class data.

Microsoft also support a distributed version of COM, which works across a network, called DCOM. DCOM enables you to send messages to an object residing on a different machine.