Johan
Johan

Reputation: 76537

Why do I get error Missing implementation?

I'm getting an error:

[DCC Error] Test.pas(10): E2291 Missing implementation of interface method ICoTest64.MyFunc

Below is a snippet from the TLB file.

// *********************************************************************//
// Interface: ICoTest64
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {76CF78FE-22A3-4C0B-B1A9-97634A453AE3}
// *********************************************************************//
  ICoTest64 = interface(IDispatch)
    ['{76CF78FE-22A3-4C0B-B1A9-97634A453AE3}']
    function MyFunc(const Range: System.OleVariant): System.OleVariant; safecall;
  end;

And here is the implementation

unit Test;

interface

uses
  SysUtils, ComObj, ComServ, ActiveX, Variants, Office2000, Excel2000, 
  adxAddIn, Test64_TLB,
  System.Classes, adxHostAppEvents, Dialogs, StdVcl;

type
  TCoTest64 = class(TadxAddin, ICoTest64)
  protected
    function MyFunc(var Range: System.OleVariant): System.OleVariant; safecall;
  end;

implementation

function TCoTest64.MyFunc(var Range: System.OleVariant): System.OleVariant;
begin
  Result:= 10;
end;

end.

As far as I can tell implementation = interface

I'm using Delphi XE2

What's wrong?

Upvotes: 0

Views: 3562

Answers (1)

David Heffernan
David Heffernan

Reputation: 612854

The function parameter lists for MyFunc do not match. The declaration in the interface ICoTest64 uses a const parameter. But your implementation in the class TCoReporting64 uses a var parameter.

Assuming that the interface declaration is correct, you need to change your code thus:

type
  TCoReporting64 = class(TadxAddin, ICoTest64)
  protected
    function MyFunc(const Range: System.OleVariant): System.OleVariant; safecall;
  end;

Upvotes: 6

Related Questions