IMethodMessage.LogicalCallContext プロパティ
現在のメソッド呼び出しの LogicalCallContext を取得します。
ReadOnly Property LogicalCallContext As LogicalCallContext
[C#]
LogicalCallContext LogicalCallContext {get;}
[C++]
__property LogicalCallContext* get_LogicalCallContext();
[JScript]
function get LogicalCallContext() : LogicalCallContext;
プロパティ値
現在のメソッド呼び出しの LogicalCallContext を取得します。
例外
例外の種類 | 条件 |
---|---|
SecurityException | 直前の呼び出し元は、インターフェイスへの参照を通じて呼び出しを実行します。この呼び出し元には、インフラストラクチャ アクセス許可がありません。 |
使用例
[Visual Basic, C#, C++] 何らかの値が論理スレッドに結び付けられているかどうかを確認する LogicalCallContext プロパティの使用方法については、次のコード例を参照してください。
Public Class MyProxy
Inherits RealProxy
Private stringUri As String
Private targetObject As MarshalByRefObject
Public Sub New(type As Type)
MyBase.New(type)
targetObject = CType(Activator.CreateInstance(type), MarshalByRefObject)
Dim myObject As ObjRef = RemotingServices.Marshal(targetObject)
stringUri = myObject.URI
End Sub 'New
Public Sub New(type As Type, targetObject As MarshalByRefObject)
MyBase.New(type)
Me.targetObject = targetObject
End Sub 'New
Public Overrides Function Invoke(message As IMessage) As IMessage
message.Properties("__Uri") = stringUri
Dim myMethodMessage As IMethodMessage = _
CType(ChannelServices.SyncDispatchMessage(message), IMethodMessage)
Console.WriteLine("---------IMethodMessage example-------")
Console.WriteLine("Method name : " + myMethodMessage.MethodName)
Console.WriteLine("LogicalCallContext has information : " + _
myMethodMessage.LogicalCallContext.HasInfo.ToString())
Console.WriteLine("Uri : " + myMethodMessage.Uri)
Return myMethodMessage
End Function 'Invoke
End Class 'MyProxy
[C#]
public class MyProxy : RealProxy
{
String stringUri;
MarshalByRefObject targetObject;
public MyProxy(Type type) : base(type)
{
targetObject = (MarshalByRefObject)Activator.CreateInstance(type);
ObjRef myObject = RemotingServices.Marshal(targetObject);
stringUri = myObject.URI;
}
public MyProxy(Type type, MarshalByRefObject targetObject) : base(type)
{
this.targetObject = targetObject;
}
public override IMessage Invoke(IMessage message)
{
message.Properties["__Uri"] = stringUri;
IMethodMessage myMethodMessage =
(IMethodMessage)ChannelServices.SyncDispatchMessage(message);
Console.WriteLine("---------IMethodMessage example-------");
Console.WriteLine("Method name : " + myMethodMessage.MethodName);
Console.WriteLine("LogicalCallContext has information : " +
myMethodMessage.LogicalCallContext.HasInfo);
Console.WriteLine("Uri : " + myMethodMessage.Uri);
return myMethodMessage;
}
}
[C++]
public __gc class MyProxy : public RealProxy
{
String* stringUri;
MarshalByRefObject* targetObject;
public:
MyProxy(Type* type) : RealProxy(type)
{
targetObject = dynamic_cast<MarshalByRefObject*>(Activator::CreateInstance(type));
ObjRef* myObject = RemotingServices::Marshal(targetObject);
stringUri = myObject->URI;
}
public:
MyProxy(Type* type, MarshalByRefObject* targetObject) : RealProxy(type)
{
this->targetObject = targetObject;
}
public:
IMessage* Invoke(IMessage* message)
{
message->Properties->Item[S"__Uri"] = stringUri;
IMethodMessage* myMethodMessage =
dynamic_cast<IMethodMessage*>(ChannelServices::SyncDispatchMessage(message));
Console::WriteLine(S"---------IMethodMessage* example-------");
Console::WriteLine(S"Method name : {0}", myMethodMessage->MethodName);
Console::WriteLine(S"LogicalCallContext has information : {0}", __box(myMethodMessage->LogicalCallContext->HasInfo));
Console::WriteLine(S"Uri : {0}", myMethodMessage->Uri);
return myMethodMessage;
}
};
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
.NET Framework セキュリティ:
- SecurityPermission (インフラストラクチャ コードを操作するために必要なアクセス許可)要求値: SecurityAction.LinkDemand; アクセス許可値: SecurityPermissionFlag.Infrastructure
参照
IMethodMessage インターフェイス | IMethodMessage メンバ | System.Runtime.Remoting.Messaging 名前空間