IMethodMessage.LogicalCallContext Property

 

Gets the LogicalCallContext for the current method call.

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

LogicalCallContext LogicalCallContext {
	[SecurityCriticalAttribute]
	get;
}

Property Value

Type: System.Runtime.Remoting.Messaging.LogicalCallContext

Gets the LogicalCallContext for the current method call.

Exception Condition
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;
   }
}

SecurityPermission

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

.NET Framework
Available since 1.1
Return to top
Show: