• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 856
  • Last Modified:

D2010 TStream abstract error

Is there an undocumented change to the TStream mechanism in D2010?
For some reason, any operation on a TStream aside from free and create gives an abstract error.  any operations such as savetostream(theStream), copyfrom, copyto, readbuffer, read, writebuffer, write.. etc..
TMemoryStream,TFileStream and TStringStream work fine.

This problem is only in D2010 and even code which was working till D2009. even in the simplest form:
example:
var
  ms:TMemoryStream;
  sm:TStream;
begin
  ms:=TMemoryStream.create;
  sm:=TStream.create;
  //ms.load operation
  ms.position :=0;
  ms.savetostream(sm,sizeof(ms));    //fails  <<---- THIS SHOULD ALWAYS WORK!!
  //..OR sm.CopyFrom(ms,sizeof(ms));  //fails
  ms.free;
  sm.free;
end;
 
0
controlr
Asked:
controlr
1 Solution
 
SteveBayCommented:
>>sm : TStream
TStream is a base class and should not be use directly. You should be using one of its descendants instead. My guess is that while this may have worked in the older version of the compiler Delphi finally decided to enforce what it has been saying in the help files for quite some time now.

From the help file:
TStream is an abstract or, in C++ terminology, pure virtual class. It should not be instantiated; it relies on abstract or pure virtual methods that must be overridden in descendant classes. Descendant stream objects, such as memory and file streams used for component streaming, are created automatically by the global functions ReadComponentRes and WriteComponentRes. For streaming other kinds of information, choose a descendant class according to the specific data and storage needs. These include
TFileStream (for working with files)
TStringStream (for manipulating in-memory strings)
TMemoryStream (for working with a memory buffer)
TBlobStream (for working with BLOB fields)  
TWinSocketStream (for reading and writing over a socket connection)  
TOleStream (for using a COM interface to read and write)  
0
 
controlrAuthor Commented:
it was so obvious.. as i had a problem on server side and thought it was a delphi error.  thanks.
0
 
Geert GruwezOracle dbaCommented:
>>ms.savetostream(sm,sizeof(ms));    //fails  <<---- THIS SHOULD ALWAYS WORK!!
The lowest class which has this procedure is a TCustomMemoryStream in D2010
The TStream doesn't even have this procedure

it's even like that in D7

check the Classes unit
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now