HomeDelphiDelphi Error – E2160 Type not allowed in OLE Automation call

Delphi Error – E2160 Type not allowed in OLE Automation call

Delphi Compiler Error

E2160 Type not allowed in OLE Automation call

Reason for the Error & Solution

If a data type cannot be converted by the compiler into a Variant, then it is not allowed in an OLE automation call.

program Produce;

  type
    Base = class
      x : Integer;
    end;

  var
    B : Base;
    V : Variant;

begin
  V.Dispatch(B);
end.

A class cannot be converted into a Variant type, so it is not allowed in an OLE call.

program Solve;


  type
    Base = class
      x : Integer;
    end;

  var
    B : Base;
    V : Variant;

begin
  V.Dispatch(B.i);
end.

The only solution to this problem is to manually convert these data types to Variants or to only use data types that can automatically be converted into a Variant.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...