| [Serializable] | 
When a remote method call is made to an object in another AppDomain, the CallContext class generates a LogicalCallContext instance that travels along with the remote call. Only objects that expose the ILogicalThreadAffinative interface and are stored in the CallContext are propagated outside the AppDomain in a LogicalCallContext. Objects that do not support this interface are not transmitted in LogicalCallContext instances with remote method calls.
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
public class ClientClass {
   public static void Main() {
      
      GenericIdentity ident = new GenericIdentity("Bob");
      GenericPrincipal prpal = new GenericPrincipal(ident, 
                                                    new string[] {"Level1"});
      LogicalCallContextData data = new LogicalCallContextData(prpal);      
      
      //Enter data into the CallContext
      CallContext.SetData("test data", data);
      
      Console.WriteLine(data.numOfAccesses);
      ChannelServices.RegisterChannel(new TcpChannel());
      RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                        "tcp://localhost:8082");
      HelloServiceClass service = new HelloServiceClass();
      if(service == null) {
          Console.WriteLine("Could not locate server.");
          return;
      }
      // call remote method
      Console.WriteLine();
      Console.WriteLine("Calling remote object");
      Console.WriteLine(service.HelloMethod("Caveman"));
      Console.WriteLine(service.HelloMethod("Spaceman"));
      Console.WriteLine(service.HelloMethod("Bob"));
      Console.WriteLine("Finished remote object call");
      Console.WriteLine();
      //Extract the returned data from the call context
      LogicalCallContextData returnedData = 
         (LogicalCallContextData)CallContext.GetData("test data");
      Console.WriteLine(data.numOfAccesses);
      Console.WriteLine(returnedData.numOfAccesses);
   }
}
    
| Equals (inherited from System.Object) | See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. | 
| FreeNamedDataSlot | Empties a data slot with the specified name. | 
| GetData | Retrieves an object with the specified name from the CallContext. | 
| GetHashCode (inherited from System.Object) | See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. | 
| GetHeaders | Returns the headers that are sent along with the method call. | 
| GetType (inherited from System.Object) | See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. | 
| SetData | Stores a given object and associates it with the specified name. | 
| SetHeaders | Sets the headers that are sent along with the method call. | 
| ToString (inherited from System.Object) | See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. | 
| Finalize (inherited from System.Object) | See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. | 
| MemberwiseClone (inherited from System.Object) | See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. | 
Hierarchy:
| 
            ~CallContext(); | 
| 
            public static void FreeNamedDataSlot( | 
name
name
using System;
using System.Text;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
public class HelloServiceClass : MarshalByRefObject {
   static int n_instances;
   int instanceNum;
   public HelloServiceClass() {
      n_instances++;
      instanceNum = n_instances;
      Console.WriteLine(this.GetType().Name + " has been created.  Instance # = {0}", instanceNum);
   }
   ~HelloServiceClass() {
      Console.WriteLine("Destroyed instance {0} of HelloServiceClass.", instanceNum);      
   }
   public String HelloMethod(String name) {
      //Extract the call context data
      LogicalCallContextData data = (LogicalCallContextData)CallContext.GetData("test data");      
      IPrincipal myPrincipal = data.Principal;
      
      //Check the user identity
      if(myPrincipal.Identity.Name == "Bob") {
         Console.WriteLine("\nHello {0}, you are identified!", myPrincipal.Identity.Name);
         Console.WriteLine(data.numOfAccesses);
      }
      else {
         Console.WriteLine("Go away! You are not identified!");
         return String.Empty;
      }
        // calculate and return result to client	
      return "Hi there " + name + ".";
   }
}
    
| 
            public virtual int GetHashCode(); | 
| 
            public static Header[] GetHeaders(); | 
| 
            public Type GetType(); | 
| 
            protected object MemberwiseClone(); | 
name
data
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
public class ClientClass {
   public static void Main() {
      
      GenericIdentity ident = new GenericIdentity("Bob");
      GenericPrincipal prpal = new GenericPrincipal(ident, 
                                                    new string[] {"Level1"});
      LogicalCallContextData data = new LogicalCallContextData(prpal);      
      
      //Enter data into the CallContext
      CallContext.SetData("test data", data);
      
      Console.WriteLine(data.numOfAccesses);
      ChannelServices.RegisterChannel(new TcpChannel());
      RemotingConfiguration.RegisterActivatedClientType(typeof(HelloServiceClass),
                                                        "tcp://localhost:8082");
      HelloServiceClass service = new HelloServiceClass();
      if(service == null) {
          Console.WriteLine("Could not locate server.");
          return;
      }
      // call remote method
      Console.WriteLine();
      Console.WriteLine("Calling remote object");
      Console.WriteLine(service.HelloMethod("Caveman"));
      Console.WriteLine(service.HelloMethod("Spaceman"));
      Console.WriteLine(service.HelloMethod("Bob"));
      Console.WriteLine("Finished remote object call");
      Console.WriteLine();
      //Extract the returned data from the call context
      LogicalCallContextData returnedData = 
         (LogicalCallContextData)CallContext.GetData("test data");
      Console.WriteLine(data.numOfAccesses);
      Console.WriteLine(returnedData.numOfAccesses);
   }
}
    
| 
            public static void SetHeaders( | 
headers
| 
            public virtual string ToString(); |