Export (0) Print
Expand All

IMethodMessage.LogicalCallContext Property

Gets the LogicalCallContext for the current method call.

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

LogicalCallContext LogicalCallContext { get; }

Property Value

Type: System.Runtime.Remoting.Messaging.LogicalCallContext
Gets the LogicalCallContext for the current method call.

ExceptionCondition
SecurityException

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;

[SecurityPermission(SecurityAction.LinkDemand)]
public MyProxy(Type type) : base(type)
{
      targetObject = (MarshalByRefObject)Activator.CreateInstance(type);
      ObjRef myObject = RemotingServices.Marshal(targetObject);
      stringUri = myObject.URI;
   }

   [SecurityPermission(SecurityAction.LinkDemand)]
   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 = 
         (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;
   }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft