IMethodMessage::LogicalCallContext Property

 

Gets the LogicalCallContext for the current method call.

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

property LogicalCallContext^ LogicalCallContext {
	[SecurityCriticalAttribute]
	LogicalCallContext^ 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.

//This sample requires full trust
[PermissionSetAttribute(SecurityAction::Demand, Name = "FullTrust")]
public ref class MyProxy: public RealProxy
{
private:
   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;
   }

   MyProxy( Type^ type, MarshalByRefObject^ targetObject )
      : RealProxy( type )
   {
      this->targetObject = targetObject;
   }

   virtual IMessage^ Invoke( IMessage^ message ) override
   {
      message->Properties[ "__Uri" ] = stringUri;
      IMethodMessage^ myMethodMessage = dynamic_cast<IMethodMessage^>(ChannelServices::SyncDispatchMessage( message ));
      Console::WriteLine( "---------IMethodMessage* example-------" );
      Console::WriteLine( "Method name : {0}", myMethodMessage->MethodName );
      Console::WriteLine( "LogicalCallContext has information : {0}", myMethodMessage->LogicalCallContext->HasInfo );
      Console::WriteLine( "Uri : {0}", 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: