Remoting Bitmaps and Sound files

  • Thread starter Thread starter Tim Shih
  • Start date Start date
T

Tim Shih

Hi, I'm looking for a way to remotely pass bitmaps and soundfiles via remoting. I have a class which contains a bitmap and I can easily access it remotely as long as I do not set a value for the bitmap. However, when i specify a value for the bitmap I get the 'Because of security restrictions, the type System.Runtime.Remoting.ObjRef cannot be accessed.' message. Now, I attempted to inherit from Bitmap to make it serializable but I am unable to inherit from that class. If anyone knows how to serialize a bitmap across the remoting boundary, your help would be greatly appreciated!

Thanks,
Tim
 
Tim,

With a Bitmap, you can call the Save method on it to write to a Stream.
I would pass a MemoryStream to this method, and then extract the byte array
from the memory stream, sending that across the remoting boundary.

Then, on the other side, when you get the byte array, you can call the
static FromStream method on the Image class to get an instance of Image that
you can probably cast to Bitmap (depending on whether the underlying
representation was Bitmap or a Metafile).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi, I'm looking for a way to remotely pass bitmaps and soundfiles via
remoting. I have a class which contains a bitmap and I can easily access it
remotely as long as I do not set a value for the bitmap. However, when i
specify a value for the bitmap I get the 'Because of security restrictions,
the type System.Runtime.Remoting.ObjRef cannot be accessed.' message. Now, I
attempted to inherit from Bitmap to make it serializable but I am unable to
inherit from that class. If anyone knows how to serialize a bitmap across
the remoting boundary, your help would be greatly appreciated!

Thanks,
Tim
 
Back
Top