Andy,
The code snippet below worked for me. The solution was to do the serialization
myself, and pass a stream object around:
MBRAndSerializableObject mbrObj = new MBRAndSerializableObject();
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
bf.SurrogateSelector = null; // Forces serialization of object rather than remote
proxy
// Actually, this is the default value but I like to
put
// it here to make things clear.
bf.Serialize( ms, mbrObj ); // Serialize your MBR
// Now pass the Memory Stream from server to client.
Hope this helps
Mark
-----Original Message-----
From: Andy Knowles [mailto:[EMAIL PROTECTED]]
Sent: 12 February 2003 01:55
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Force serialization of an MBR object
Hi
I'm looking for a way to force serialization of an object that derives
indirectly from MarshalByRefObject when it's returned from a remote method
call.
I tried implementing ISerializable to no avail, and I'm trying to write
another class implementing ISerializationSurrogate to handle serialization
of the object. But, I can't figure out how to register the surrogate so
that it works automatically with any formatters that remoting is using.
A little more info: The class derives from Stream, which is MBR, but is
only a wrapper to call remote methods on another object and impersonate
Stream functionality. I can construct this 'ClientStream' on the client
after I've already obtained a reference to the remote object, but I'd rather
construct it on the server side and serialize it back to the client.
On another issue, is there anyway to get a callback on the server when an
MBR object's lease expires?
Thanks in advance
Andy
_________________________________________________________________
Hotmail now available on Australian mobile phones. Go to
http://ninemsn.com.au/mobilecentral/hotmail_mobile.asp
************************************************************************
This email (including any attachments to it) is confidential, legally
privileged, subject to copyright and is sent for the personal attention
of the intended recipient only. If you have received this email in error,
please advise us immediately and delete it. You are notified that
disclosing, copying, distributing or taking any action in reliance on
the contents of this information is strictly prohibited.Although we have
taken reasonable precautions to ensure no viruses are present in this
email, we cannot accept responsibility for any loss or damage arising
from the viruses in this email or attachments.We exclude any liability
for the content of this email, or for the consequences of any actions
taken on the basis of the information provided in this email or its
attachments, unless that information is subsequently confirmed in
writing. If this email contains an offer, that should be considered
as an invitation to treat.
*************************************************************************
==================================================================