ClientSponsor クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<ComVisibleAttribute(True)> _ Public Class ClientSponsor Inherits MarshalByRefObject Implements ISponsor

有効期間スポンサの現在の実装は、更新時間として必要な値を TimeSpan を指定することにより、オブジェクトのスポンサとして使用できます。
![]() |
---|
このクラスは、リンク確認要求と継承確認要求をクラス レベルで行います。直前の呼び出し元または派生クラスにインフラストラクチャ アクセス許可がない場合、SecurityException がスローされます。セキュリティ要求の詳細については、「リンク確認要求」および「継承確認要求」を参照してください。 |

クラスでアクティブ化されるリモート オブジェクトの有効期間を延長する ClientSponsor クラスの例を次に示します。
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
using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; using System.Runtime.Remoting.Lifetime; namespace RemotingSamples { class HelloClient { static void Main() { // Register a channel. TcpChannel myChannel = new TcpChannel (); ChannelServices.RegisterChannel(myChannel); RemotingConfiguration.RegisterActivatedClientType( typeof(HelloService),"tcp://localhost:8085/"); // Get the remote object. HelloService myService = new HelloService(); // Get a sponsor for renewal of time. ClientSponsor mySponsor = new ClientSponsor(); // Register the service with sponsor. mySponsor.Register(myService); // Set renewaltime. mySponsor.RenewalTime = TimeSpan.FromMinutes(2); // Renew the lease. ILease myLease = (ILease)mySponsor.InitializeLifetimeService(); TimeSpan myTime = mySponsor.Renewal(myLease); Console.WriteLine("Renewed time in minutes is " + myTime.Minutes.ToString()); // Call the remote method. Console.WriteLine(myService.HelloMethod("World")); // Unregister the channel. mySponsor.Unregister(myService); mySponsor.Close(); } } }
#using <system.dll> #using <system.runtime.remoting.dll> #using <ClientSponsor_Share.dll> using namespace System; using namespace System::Runtime::Remoting; using namespace System::Runtime::Remoting::Channels; using namespace System::Runtime::Remoting::Channels::Tcp; using namespace System::Runtime::Remoting::Lifetime; int main() { // Register a channel. TcpChannel^ myChannel = gcnew TcpChannel; ChannelServices::RegisterChannel( myChannel ); RemotingConfiguration::RegisterActivatedClientType( RemotingSamples::HelloService::typeid, "tcp://localhost:8085/" ); // Get the remote Object*. RemotingSamples::HelloService ^ myService = gcnew RemotingSamples::HelloService; // Get a sponsor for renewal of time. ClientSponsor^ mySponsor = gcnew ClientSponsor; // Register the service with sponsor. mySponsor->Register( myService ); // Set renewaltime. mySponsor->RenewalTime = TimeSpan::FromMinutes( 2 ); // Renew the lease. ILease^ myLease = dynamic_cast<ILease^>(mySponsor->InitializeLifetimeService()); TimeSpan myTime = mySponsor->Renewal( myLease ); Console::WriteLine( "Renewed time in minutes is {0}", myTime.Minutes ); // Call the remote method. Console::WriteLine( myService->HelloMethod( "World" ) ); // Unregister the channel. mySponsor->Unregister( myService ); mySponsor->Close(); }

- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)。要求値 : SecurityAction.LinkDemand; アクセス許可値 : SecurityPermissionFlag.Infrastructure
- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)。要求値 : SecurityAction.InheritanceDemand; アクセス許可値 : SecurityPermissionFlag.Infrastructure

System.MarshalByRefObject
System.Runtime.Remoting.Lifetime.ClientSponsor


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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からClientSponsor クラスを検索する場合は、下記のリンクをクリックしてください。

- ClientSponsor クラスのページへのリンク