ILNATIVE

Exposes COBOL 01 level data items as native .NET types where possible.

Syntax:
>>-.----.---ILNATIVE----------><
   |    |        
   +-NO-+  
Parameters:

None

Properties:
Default: ILNATIVE
IDE equivalent: None. You can specify ILNATIVE as an additional Compiler directive under Project > Properties > Configuration Properties > COBOL
Comments:

A COBOL data item that is represented as an IL native type performs significantly better than one that isn't. However, there are some situations where using IL native types is not suitable, such as when the call arguments do not match in dynamic call.

When ILNATIVE is specified:

When ILNATIVE is specified, the Compiler usually converts parameters in the calling program to the appropriate type, by examining the target method signature. This signature is available if the method is in the same source module as the calling program or in a module identified by the ILSOURCE directive or in an assembly identified by an ILREF directive.

Where the called program is not known at compile time or not available until run time, the calling program sets up parameter types based on only the data items in the CALL statement. At run time the types of the parameters might not match those in the target method and this causes the .NET CLR to raise a System.ArgumentException because it can't convert the data. You can avoid this by specifying the NOILNATIVE directive for both the calling and the called program.

Example:

The following programs demonstrate a case for compiling with NOILNATIVE:

cmain.cbl

      01 ws-data pic 9(4) comp-5.
       procedure division.
       call “csub” using ws-data.

csub.cbl

       linkage section.
       01 ls-data.
          03 ls-value pic 9(4) comp-5.

       procedure division using ls-data.
          move 100 to ls-value.
          exit program.

Compile the two programs independently, with the default setting of ILNATIVE, using commands such as:

cobol cmain ilgen;
cobol csub ilgen(sub);

When you run the program cmain, an ArgumentException is raised at run time due to the different types of the ws-data and ls-data data items.

However, if you specify NOILNATIVE directive for both programs, as follows, both data items will be represented with the same type and so the argument will be successfully passed to the subprogram.

cobol cmain ilgen noilnative;
cobol csub ilgen(sub) noilnative;
See Also: