IMethodMessage.LogicalCallContext Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets the LogicalCallContext for the current method call.

Namespace:   System.Runtime.Remoting.Messaging
Assembly:  mscorlib (in mscorlib.dll)

LogicalCallContext LogicalCallContext {

Property Value

Type: System.Runtime.Remoting.Messaging.LogicalCallContext

Gets the LogicalCallContext for the current method call.

Exception Condition

The immediate caller makes the call through a reference to the interface and does not have infrastructure permission.

The following example code shows how to use the LogicalCallContext property to determine whether any values are attached to the logical thread.

   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;

[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)]
   public override IMessage Invoke(IMessage message)
      message.Properties["__Uri"] = stringUri;
      IMethodMessage myMethodMessage = 

      Console.WriteLine("---------IMethodMessage example-------");
      Console.WriteLine("Method name : " + myMethodMessage.MethodName);
      Console.WriteLine("LogicalCallContext has information : " +
      Console.WriteLine("Uri : " + myMethodMessage.Uri);

      return myMethodMessage;


for operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission value: SecurityPermissionFlag.Infrastructure

.NET Framework
Available since 1.1
Return to top