Hi Andy,
> On another issue, is there anyway to get a callback on the server when
> an MBR object's lease expires?
>
Say you wanted to dispose of an object when its lease expires you do
something like this...
using System.Runtime.Remoting.Services;
public class DisposeOnDisconnectionObject : IDisposable
{
public DisposeOnDisconnectionObject ()
{
ITrackingHandler trackingHandler
= new DisposingTrackingHandler(this);
TrackingServices.RegisterTrackingHandler(trackingHandler);
}
public void Dispose()
{
Console.WriteLine("Disposing of object...");
}
private class MyTrackingHandler : ITrackingHandler
{
public MyTrackingHandler(IDisposable disposable)
{
_disposable = disposable;
}
private IDisposable _disposable;
public void DisconnectedObject(object obj)
{
if(obj == _disposable)
{
TrackingServices.UnregisterTrackingHandler(this);
_disposable.Dispose();
}
}
public void MarshaledObject(object obj, ObjRef or) {}
public void UnmarshaledObject(object obj, ObjRef or) {}
}
}
I haven't compiled and tested it (there could be typos), but something
like this would work.
Good luck, Jamie.
NUnitAddin - Point and Test NUnit integration for Visual Studio.NET
http://dotnetweblogs.com/NUnitAddin/
-----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