Groups | Blog | Home
all groups > dotnet remoting > may 2005 >

dotnet remoting : Questions about MarshalByRefObject.InitializeLifetimeService


Roy Chastain
5/26/2005 10:55:21 AM
I have done some testing and it appears that the framework does not call InitializeLifetimeService until just before returning the
object reference to the client.

I would like to use the ILease returned from InitializeLifetimeService in the server code before returning to the client. I have
observed that a call to GetLifetimeService returns a null, so I put code in to explicitly call InitializeLifetimeService on my
newly created object. I also put code in the override for InitializeLifetimeService to display when it was called and what the
state was. I received two displays both with the state of Initial. One from my explicit call and on from the framework as it was
returning to the client.

For this I would say that either
1) - I am totally messed up
or
2) - You just can't do this

I would appreciate any understanding about this issue and/or a suggestion of a way that I can acquire and use an ILease prior to
the return to the client.
-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
Roy Chastain
5/27/2005 12:00:00 AM
I have discovered that this is (at least one) reason that RemotingServices.Marshal exists. Calling it in the server code forces
InitializeLifetimeService to get called and that allows the lease information to be used on the server prior to that return.

[quoted text, click to view]

-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
AddThis Social Bookmark Button