今天又遇到一怪事, FDQuery 在服务器 savestream 传回了客户端。 客户端接收后 loadfromstream 接收都正常。 但当我把客户端封装成 dll 时,loadfromstream 就会报错: Invalid class typecast .
{-------------------------------------------------------------------------------}
procedure TFDStorage.Open(AResOpts: TObject; AEncoder: TObject;
const AFileName: String; AStream: TStream; AMode: TFDStorageMode);
begin
FResOpts := AResOpts as TFDBottomResourceOptions;
FEncoder := AEncoder as TFDEncoder;
ASSERT((AStream <> nil) or (AFileName <> '') or
(FResOpts <> nil) and (FResOpts.PersistentFileName <> ''));
FMode := AMode;
procedure TFDStorage.Open(AResOpts: TObject; AEncoder: TObject;
const AFileName: String; AStream: TStream; AMode: TFDStorageMode);
begin
FResOpts := AResOpts as TFDBottomResourceOptions;
FEncoder := AEncoder as TFDEncoder;
ASSERT((AStream <> nil) or (AFileName <> '') or
(FResOpts <> nil) and (FResOpts.PersistentFileName <> ''));
FMode := AMode;
.....
....
跟踪后发现停在这个转换上(红字)
unit FireDAC.Stan.Storage; 这个单元
unit FireDAC.Stan.Storage; 这个单元
折腾了半天,最后发现, 问题出在从外界传入的 TFDQuery 实例(即使用TFDMemTable也是一样),必须在dll内部create,才能正常使用, 而create则必须引用单元
FireDAC.dApt
哎,这种搞得太隐蔽了