【问题标题】:E2134 Error in Turbopower LockBox code when building with runtime type informationE2134 使用运行时类型信息构建时 Turbopower LockBox 代码出错
【发布时间】:2021-04-09 12:27:54
【问题描述】:

我必须使用运行时类型信息来构建我的程序,所以编译器选项Emit runtime type information被选中。
但是有了这个设置,LockBox3 单元 uTPLb_codecIntf.pas 在包含 实现 的行上给出了错误 E2134 Type has no type info(参见源代码的底部)。

LockBox3\run\(源)文件夹位于我的库路径中(由安装指定)。
LockBox DCU 的地址为d:\LockBox3\packages\Sydney\Delphi\Win32\Release\,日期自安装之日起。

如何在 RTTI 可用的情况下消除错误消息?

编辑 FWIW,这些是uTPLb_codecIntf.pas的内容:

interface
uses SysUtils, Classes, uTPLb_StreamCipher, uTPLb_BlockCipher,
     uTPLb_CryptographicLibrary;

type
TCodecMode = (cmUnitialized, cmIdle, cmEncrypting, cmDecrypting);

TOnEncDecProgress = function ( Sender: TObject; CountBytesProcessed: int64): boolean of object;

TGenerateAsymetricKeyPairProgress = procedure (
  Sender: TObject; CountPrimalityTests: integer;
  var doAbort: boolean) of object;


ICodec = interface
  ['{48B3116A-5681-4E79-9013-8EC89BAC5B35}']
    procedure SetStreamCipher( const Value: IStreamCipher);
    procedure SetBlockCipher ( const Value: IBlockCipher);
    procedure SetChainMode   ( const Value: IBlockChainingModel);
    function  GetMode: TCodecMode;
    function  GetStreamCipher: IStreamCipher;
    function  GetBlockCipher : IBlockCipher;
    function  GetChainMode   : IBlockChainingModel;
    function  GetOnProgress  : TOnEncDecProgress;
    procedure SetOnProgress( Value: TOnEncDecProgress);
    function  GetAsymetricKeySizeInBits: cardinal;
    procedure SetAsymetricKeySizeInBits( value: cardinal);
    function  GetAsymGenProgressEvent: TGenerateAsymetricKeyPairProgress;
    procedure SetAsymGenProgressEvent( Value: TGenerateAsymetricKeyPairProgress);
    function  GetKey: TSymetricKey;

    function  GetCipherDisplayName( Lib: TCryptographicLibrary): string;

    procedure Init(const Key: string; AEncoding: TEncoding);
    procedure SaveKeyToStream( Store: TStream);
    procedure InitFromStream( Store: TStream);
    procedure InitFromKey( Key: TSymetricKey);   // Transfers ownership.
    procedure Reset;
    procedure Burn( doIncludeBurnKey: boolean);

    // Asymetric support
    function  isAsymetric: boolean;
    procedure InitFromGeneratedAsymetricKeyPair;

    procedure Sign(
      Document, Signature: TStream;
      ProgressSender: TObject;
      ProgressEvent: TOnEncDecProgress;
      SigningKeys_PrivatePart: TObject;  // Must be uTPLb_Asymetric.TAsymtricKeyPart
      var wasAborted: boolean);

    function VerifySignature(
      Document, Signature: TStream;
      ProgressSender: TObject;
      ProgressEvent: TOnEncDecProgress;
      SigningKeys_PublicPart: TObject; // Must be uTPLb_Asymetric.TAsymtricKeyPart
      var wasAborted: boolean): boolean;


    procedure Begin_EncryptMemory( CipherText{out}: TStream);
    procedure EncryptMemory(const Plaintext: TBytes; PlaintextLen: Integer);
    procedure End_EncryptMemory;

    procedure Begin_DecryptMemory( PlainText{out}: TStream);
    procedure DecryptMemory( const CipherText{in}; CiphertextLen: integer);
    procedure End_DecryptMemory;

    procedure EncryptStream( Plaintext, CipherText: TStream);
    procedure DecryptStream( Plaintext, CipherText: TStream);

    procedure EncryptFile( const Plaintext_FileName, CipherText_FileName: string);
    procedure DecryptFile( const Plaintext_FileName, CipherText_FileName: string);

    procedure EncryptString(const Plaintext: string; var CipherText_Base64: string; AEncoding: TEncoding);
    procedure DecryptString(var Plaintext: string; const CipherText_Base64: string; AEncoding: TEncoding);

    procedure EncryptAnsiString(const Plaintext: string; var CipherText_Base64: string);
    procedure DecryptAnsiString(var Plaintext: string; const CipherText_Base64: string);

    function  GetAborted: boolean;
    procedure SetAborted( Value: boolean);
    function  GetAdvancedOptions2 : TSymetricEncryptionOptionSet;
    procedure SetAdvancedOptions2( Value: TSymetricEncryptionOptionSet);
    function  GetOnSetIV: TSetMemStreamProc;
    procedure SetOnSetIV( Value: TSetMemStreamProc);

    property  Mode: TCodecMode                   read GetMode;
    property  Key: TSymetricKey                  read GetKey;
    property  StreamCipher: IStreamCipher        read GetStreamCipher write SetStreamCipher;
    property  BlockCipher : IBlockCipher         read GetBlockCipher  write SetBlockCipher;
    property  ChainMode   : IBlockChainingModel  read GetChainMode    write SetChainMode;
    property  OnProgress  : TOnEncDecProgress    read GetonProgress   write SetOnProgress;
    property  AsymetricKeySizeInBits: cardinal   read GetAsymetricKeySizeInBits
                                                 write SetAsymetricKeySizeInBits;
    property  OnAsymGenProgress: TGenerateAsymetricKeyPairProgress
                                           read GetAsymGenProgressEvent write SetAsymGenProgressEvent;
    property isUserAborted: boolean              read GetAborted write SetAborted;
  end;


implementation

end.

【问题讨论】:

    标签: delphi rtti delphi-10.4-sydney lockbox-3


    【解决方案1】:

    LockBox 作者建议将源文件夹放在您的库路径中,这并不意味着您必须这样做。追踪他们的代码很方便,但不是必需的。

    只需从该列表中删除它们并将 .dcu 目录 d:\LockBox3\packages\Sydney\Delphi\Win32\Release\ 添加到其中。

    这会使错误消失,并且我不需要在 LockBox 源中使用 RTTI。

    【讨论】:

      【解决方案2】:

      您需要使用运行时信息重建 dcus。执行此操作的最简单方法(也仅包括此项目中的 dcu,而不是所有项目)是在您的项目中包含源文件 uTPLb_codecIntf.pas 并构建项目。根据您需要的 RTTI,您可能需要对其他源文件重复该过程。

      【讨论】:

      • 这正是最初导致错误的原因:他们正在重新构建(DCU 文件最终位于我在项目选项中指定的 DCU 输出文件夹中) .
      • 可能是依赖源导致错误,因此使用子句中的文件之一。错误是否发生在特定行上?如果是这样,该行是否有来自不同单元的类类型?如果是这样,您还需要将该单元包含在您的项目中。以此类推。
      • 我的两个单元的 Uses 子句中有 uTPLb_Constants, uTPLb_CryptographicLibrary, uTPLb_BaseNonVisualComponent, uTPLb_Codec
      • 对不起,我的意思是在 uTPLb_codecIntf.pas 的 uses 子句中。本单元中的一个类可以引用另一个单元中尚未重建的类。该单元的原始 dcu(没有 RTTI 信息)仍然对项目可见。该单元也需要在您的项目中,以便可以重建。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 2010-11-27
      相关资源
      最近更新 更多