E2176 OLE オートメーション部に間違った型があります :'%s' (Delphi)

提供: RAD Studio
移動先: 案内検索

エラーと警告のメッセージ(Delphi) への移動

<typename> は OLE オートメーション部で使用できない型です。オートメーション部では有効なすべての Delphi 言語型のうちの一部分だけが使用できます。


program Produce;

  type
    Base = class
      function GetC : Char;
      procedure SetC(c : Char);
    automated
      property Ch : Char read GetC write SetC dispid 151;
    end;

  procedure Base.SetC(c : Char);
  begin
  end;

  function Base.GetC : Char;
  begin GetC := '!';
  end;

begin
end.

{ 文字型は automated 部では使用できない型なので,Ch を宣言するとコンパイルエラーになる }


program Solve;

  type
    Base = class
      function GetC : String;
      procedure SetC(c : String);
    automated
      property Ch : String read GetC write SetC dispid 151;
    end;

  procedure Base.SetC(c : String);
  begin
  end;

  function Base.GetC : String;
  begin GetC := '!';
  end;

begin
end.

{ この問題の解決方法は 2 つある。1 つはエラーを起こした宣言を automated 部の外へ出す方法である。もう 1 つはエラーを起こした型を automated 部で使用できる型に変更する方法である }