This documentation is archived and is not being maintained.

IChannelDataStore Interface

Stores channel data for the remoting channels.

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

[ComVisibleAttribute(true)]
public interface IChannelDataStore

Channels that want to use the channel sink architecture must implement this interface on their ChannelData object.

using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Services;
using System.Security.Permissions;

public class ServerProcess
{
   [PermissionSet(SecurityAction.LinkDemand)]
   public static void Main()
   {

      TcpChannel myChannel = new TcpChannel(8085);
      ChannelServices.RegisterChannel(myChannel);

      MyServiceClass myService  = new MyServiceClass();

      // After the channel is registered, register the object 
      // with remoting infrastructure by calling Marshal method.
      ObjRef myObjRef = RemotingServices.Marshal(myService,"TcpService");

      // Get the information contributed by active channel.
      IChannelInfo myChannelInfo = myObjRef.ChannelInfo;
      IChannelDataStore myIChannelData;
      foreach(object myChannelData in myChannelInfo.ChannelData)
      {
         if(myChannelData is IChannelDataStore)
         {
            myIChannelData = (IChannelDataStore)myChannelData;
            foreach(string myUri in myIChannelData.ChannelUris)
               Console.WriteLine("Channel Uris are -> " + myUri);
            // Add custom data.
            string myKey = "Key1";
            myIChannelData[myKey] = "My Data";
            Console.WriteLine(myIChannelData[myKey].ToString());
         }
      }

   }
}

// Marshal ByRef Object class. 
public class MyServiceClass : MarshalByRefObject
{
   public string HelloWorld()
   {
      return "Hello World";
   }
}
#using <mscorlib.dll>
#using <System.Runtime.Remoting.dll>
#using <System.dll>
using namespace System;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Channels::Tcp;
using namespace System::Runtime::Remoting::Services;

// Marshal ByRef Object class.
public __gc class MyServiceClass : public MarshalByRefObject
{
public:
   String* HelloWorld()
   {
      return S"Hello World";
   }
};

int main()
{

   TcpChannel* myChannel = new TcpChannel(8085);
   ChannelServices::RegisterChannel(myChannel);

   MyServiceClass* myService  = new MyServiceClass();

   // After the channel is registered, register the object
   // with remoting infrastructure by calling Marshal method.
   ObjRef* myObjRef = RemotingServices::Marshal(myService,S"TcpService");

   // Get the information contributed by active channel.
   IChannelInfo* myChannelInfo = myObjRef->ChannelInfo;
   IChannelDataStore* myIChannelData;
   System::Collections::IEnumerator* myEnum = myChannelInfo->ChannelData->GetEnumerator();
   while (myEnum->MoveNext())
   {
      Object* myChannelData = __try_cast<Object*>(myEnum->Current);
      if(dynamic_cast<IChannelDataStore*>(myChannelData))
      {
         myIChannelData = dynamic_cast<IChannelDataStore*>(myChannelData);
         System::Collections::IEnumerator* myEnum1 = myIChannelData->ChannelUris->GetEnumerator();
         while (myEnum1->MoveNext())
         {
            String* myUri = __try_cast<String*>(myEnum1->Current);
            Console::WriteLine(S"Channel Uris are -> {0}", myUri);
         }
         // Add custom data.
         String* myKey = S"Key1";
         myIChannelData->Item[myKey] = S"My Data";
         Console::WriteLine(myIChannelData->Item[myKey]);
      }
   }


}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: