ClientSponsor Class
Assembly: mscorlib (in mscorlib.dll)
'Declaration <ComVisibleAttribute(True)> _ Public Class ClientSponsor Inherits MarshalByRefObject Implements ISponsor 'Usage Dim instance As ClientSponsor
/** @attribute ComVisibleAttribute(true) */ public class ClientSponsor extends MarshalByRefObject implements ISponsor
ComVisibleAttribute(true) public class ClientSponsor extends MarshalByRefObject implements ISponsor
The current lifetime sponsor implementation can be used to sponsor objects by specifying the required renewal TimeSpan.
Note |
|---|
| This class makes a link demand and an inheritance demand at the class level. A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. For details about security demands, see Link Demands and Inheritance Demands. |
The following example illustrates the ClientSponsor class to extend the life of a class-activated remote object.
Imports System Imports System.Runtime.Remoting Imports System.Runtime.Remoting.Channels Imports System.Runtime.Remoting.Channels.Tcp Imports System.Runtime.Remoting.Lifetime Namespace RemotingSamples Class HelloClient Shared Sub Main() ' Register a channel. Dim myChannel As New TcpChannel() ChannelServices.RegisterChannel(myChannel) RemotingConfiguration.RegisterActivatedClientType( _ GetType(HelloService), "tcp://localhost:8085") ' Get the remote object. Dim myService As New HelloService() ' Get a sponsor for renewal of time. Dim mySponsor As New ClientSponsor() ' Register the service with sponsor. mySponsor.Register(myService) ' Set renewaltime. mySponsor.RenewalTime = TimeSpan.FromMinutes(2) ' Renew the lease. Dim myLease As ILease = CType(mySponsor.InitializeLifetimeService(), ILease) Dim myTime As TimeSpan = mySponsor.Renewal(myLease) Console.WriteLine("Renewed time in minutes is " & myTime.Minutes) ' Call the remote method. Console.WriteLine(myService.HelloMethod("World")) ' Unregister the channel. mySponsor.Unregister(myService) mySponsor.Close() End Sub 'Main End Class 'HelloClient End Namespace 'RemotingSamples
- SecurityPermission for operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission Value: SecurityPermissionFlag.Infrastructure
- SecurityPermission for operating with infrastructure code. Demand value: SecurityAction.InheritanceDemand; Permission Value: SecurityPermissionFlag.Infrastructure
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Note