UrlAttributeとは? わかりやすく解説

UrlAttribute クラス

アクティブ化が発生するところで URL を指定するために、呼び出し側で使用できる属性を定義します。このクラスは継承できません。

名前空間: System.Runtime.Remoting.Activation
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 UrlAttribute
    Inherits ContextAttribute
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class UrlAttribute : ContextAttribute
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class UrlAttribute sealed : public
 ContextAttribute
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class UrlAttribute extends ContextAttribute
SerializableAttribute 
ComVisibleAttribute(true) 
public final class UrlAttribute extends
 ContextAttribute
解説解説
使用例使用例

UrlAttribute を使用して、クライアント側でアクティブ化されるリモート処理を設定するコード例を次に示します。この例には、クライアント、サーバー、およびクライアントとサーバーから使用されるリモート オブジェクトの 3 つの部分が含まれます。

クライアントのコード例を次に示します。

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Security.Permissions;

public class Client
{
[SecurityPermission(SecurityAction.Demand)]
    [STAThread]
    public static void Main()
    {
        // Report the initial status.
        Console.WriteLine("Starting client.");

        // Register the TCP channel.
        ChannelServices.RegisterChannel(new TcpChannel());

        // Create a url attribute object.
        UrlAttribute attribute = 
            new UrlAttribute("tcp://localhost:1234/RemoteApp");
        Console.WriteLine("UrlAttribute value: {0}", attribute.UrlValue);
        object[] activationAttributes = new object[] { attribute
 };

        // Register the client for the remote object.
        RemotingConfiguration.RegisterActivatedClientType(
            typeof(RemoteObject), 
            "tcp://localhost:1234/RemoteApp");

        // Activate the remote object.
        Console.WriteLine("Activating remote object.");
        RemoteObject obj = (RemoteObject) Activator.CreateInstance(
            typeof(RemoteObject), null, activationAttributes);

        // Invoke a method on the remote object.
        Console.WriteLine("Invoking Hello() on remote object.");
        obj.Hello();

        // Inform the user that the program is exiting.
        Console.WriteLine("The client is exiting.");
    }
}
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using "RemoteObject.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Activation;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;

[STAThread]
int main()
{
   
   // Report initial status.
   Console::WriteLine( "Client starting." );
   
   // Register TCP channel.
   ChannelServices::RegisterChannel( gcnew TcpChannel );
   
   // Create UrlAttribute.
   UrlAttribute^ attribute = gcnew UrlAttribute( "tcp://localhost:1234/RemoteApp"
 );
   Console::WriteLine( "UrlAttribute value: {0}", attribute->UrlValue
 );
   
   array<Object^>^activationAttributes = {attribute};
   
   // Use UrlAttribute to register for client activated remote object.
   RemotingConfiguration::RegisterActivatedClientType( RemoteObject::typeid, "tcp://localhost:1234/RemoteApp"
 );
   
   // Activate remote object.
   Console::WriteLine( "Activating remote object." );
   RemoteObject ^ obj = dynamic_cast<RemoteObject^>(Activator::CreateInstance(
 RemoteObject::typeid, nullptr, activationAttributes ));
   
   // Invoke a method on it.
   Console::WriteLine( "Invoking Hello() on remote object." );
   obj->Hello();
   
   // Inform user of termination.
   Console::WriteLine( "Terminating client." );
}

このクライアントのサーバーのコード例を次に示します。

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

public class Server
{
    [STAThread]
    public static void Main()
    {
        // Report the status to the user.
        Console.WriteLine("Starting server.");

        // Register the TCP channel.
        ChannelServices.RegisterChannel(new TcpChannel(1234));

        // Set the application name.
        RemotingConfiguration.ApplicationName = "RemoteApp";

        // Register the object for remoting.
        RemotingConfiguration.RegisterActivatedServiceType(
            typeof(RemoteObject));

        // Wait until the user presses ENTER.
        Console.WriteLine("Press ENTER to exit.");
        Console.ReadLine();
        Console.WriteLine("The server is exiting.");
    }
}
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using "RemoteObject.dll"

using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;

[STAThread]
int main()
{
   
   // Report status to user.
   Console::WriteLine( "Server starting." );
   
   // Register the TCP channel.
   ChannelServices::RegisterChannel( gcnew TcpChannel( 1234 ) );
   
   // Set application name.
   RemotingConfiguration::ApplicationName = "RemoteApp";
   
   // Register object for client activated remoting.
   RemotingConfiguration::RegisterActivatedServiceType( RemoteObject::typeid );
   
   // Wait until termination.
   Console::WriteLine( "Press enter to end." );
   Console::ReadLine();
   Console::WriteLine( "Terminating server." );
}

クライアントとサーバーから使用されるリモート オブジェクトのコード例を次に示します。

using System;
using System.Security;
using System.Security.Permissions;

public class RemoteObject : MarshalByRefObject
{
    public RemoteObject()
    {
        Console.WriteLine("You have called the constructor.");
    }

    public void Hello()
    {
        Console.WriteLine("You have called Hello().");
    }
}
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;

[assembly:AllowPartiallyTrustedCallersAttribute];
public ref class RemoteObject: public
 MarshalByRefObject
{
public:
   RemoteObject()
   {
      
      // Report object construction to server's console.
      Console::WriteLine( "You have called the constructor." );
   }

   void Hello()
   {
      
      // Report method invocation to server's console.
      Console::WriteLine( "You have called Hello()." );
   }

};

継承階層継承階層
System.Object
   System.Attribute
     System.Runtime.Remoting.Contexts.ContextAttribute
      System.Runtime.Remoting.Activation.UrlAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
UrlAttribute メンバ
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty

UrlAttribute コンストラクタ

UrlAttribute クラスの新しいインスタンスを作成します。

名前空間: System.Runtime.Remoting.Activation
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    callsiteURL As String _
)
Dim callsiteURL As String

Dim instance As New UrlAttribute(callsiteURL)
public UrlAttribute (
    string callsiteURL
)
public:
UrlAttribute (
    String^ callsiteURL
)
public UrlAttribute (
    String callsiteURL
)
public function UrlAttribute (
    callsiteURL : String
)

パラメータ

callsiteURL

呼び出し側の URL。

例外例外
例外の種類条件

ArgumentNullException

callsiteURL パラメータが null 参照 (Visual Basic では Nothing) です。

SecurityException

直前の呼び出し元に、インフラストラクチャ アクセス許可がありません。

使用例使用例

UrlAttribute コンストラクタの使用方法を次のコード例に示します。

// Create a url attribute object.
UrlAttribute attribute = 
    new UrlAttribute("tcp://localhost:1234/RemoteApp");
Console.WriteLine("UrlAttribute value: {0}", attribute.UrlValue);
// Create UrlAttribute.
UrlAttribute^ attribute = gcnew UrlAttribute( "tcp://localhost:1234/RemoteApp"
 );
Console::WriteLine( "UrlAttribute value: {0}", attribute->UrlValue );

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
UrlAttribute クラス
UrlAttribute メンバ
System.Runtime.Remoting.Activation 名前空間

UrlAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Name  コンテキスト属性の名前を取得します。 ( ContextAttribute から継承されます。)
パブリック プロパティ TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。)
パブリック プロパティ UrlValue UrlAttribute の URL 値を取得します。
参照参照

関連項目

UrlAttribute クラス
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty

UrlAttribute メソッド


パブリック メソッドパブリック メソッド

  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。  
パブリック メソッド Freeze  コンテキストが固定されるときに呼び出されます。 ( ContextAttribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 現在の UrlAttribute のハッシュ値を返します。
パブリック メソッド GetPropertiesForNewContext オーバーライドされます。 指定した URL で、コンテキストと、そのコンテキスト内のサーバー オブジェクトの作成を強制します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsContextOK オーバーライドされます。 指定した Context が UrlAttribute の要件を満たしているかどうかを示すブール値を返します。
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド IsNewContextOK  コンテキスト プロパティと新しいコンテキストとの間に互換性があるかどうかを示す Boolean 値を返します。 ( ContextAttribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
参照参照

関連項目

UrlAttribute クラス
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty

UrlAttribute メンバ

アクティブ化が発生するところで URL を指定するために、呼び出し側で使用できる属性を定義します。このクラスは継承できません。

UrlAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド UrlAttribute UrlAttribute クラスの新しいインスタンスを作成します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Name  コンテキスト属性の名前を取得します。(ContextAttribute から継承されます。)
パブリック プロパティ TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。)
パブリック プロパティ UrlValue UrlAttribute の URL 値を取得します。
パブリック メソッドパブリック メソッド
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。  
パブリック メソッド Freeze  コンテキストが固定されるときに呼び出されます。 (ContextAttribute から継承されます。)
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 現在の UrlAttribute のハッシュ値を返します。
パブリック メソッド GetPropertiesForNewContext オーバーライドされます。 指定した URL で、コンテキストと、そのコンテキスト内のサーバー オブジェクトの作成を強制します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsContextOK オーバーライドされます。 指定した Context が UrlAttribute の要件を満たしているかどうかを示すブール値を返します。
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド IsNewContextOK  コンテキスト プロパティと新しいコンテキストとの間に互換性があるかどうかを示す Boolean 値を返します。 (ContextAttribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
参照参照

関連項目

UrlAttribute クラス
System.Runtime.Remoting.Activation 名前空間
ContextAttribute
IContextProperty



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「UrlAttribute」の関連用語

UrlAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



UrlAttributeのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS