GetObject ( file ), is it possible to "cast" a byte array to an object?

  • Thread starter Thread starter Robin Tucker
  • Start date Start date
R

Robin Tucker

This may sound daft, so please forgive me for asking, but is it possible
that given an array of bytes, which represents an object loaded from disk,
is it possible to cast the bytes to an interface? For example, at present,
I am extracting data blobs from my database and writing them to disk. Then
I am using CType(GetObject (theFile), ITheInterface) to get an interface to
the object. It would be much more efficient if I could just read the bytes
from the database and get the IInterface pointer to it there and then
without having to write them to disk first.

Any idea people?
 
* "Robin Tucker said:
This may sound daft, so please forgive me for asking, but is it possible
that given an array of bytes, which represents an object loaded from disk,
is it possible to cast the bytes to an interface? For example, at present,
I am extracting data blobs from my database and writing them to disk. Then
I am using CType(GetObject (theFile), ITheInterface) to get an interface to
the object. It would be much more efficient if I could just read the bytes
from the database and get the IInterface pointer to it there and then
without having to write them to disk first.

You can make a structure persistent and load it with
'FileSystem.FileGet'. Or you can deserialize a serialized object.

<http://www.mvps.org/dotnet/dotnet/samples/miscsamples/downloads/XmlSerialization.zip>
 
Back
Top