This documentation is archived and is not being maintained.

IChannelSender Interface

Provides required functions and properties for the sender channels.

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

[ComVisibleAttribute(true)]
public interface IChannelSender : IChannel

The sending side of channels must expose the IChannelSender interface.

using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Channels.Http;
using System.Security.Permissions;

public class MyClient
{
   [PermissionSet(SecurityAction.LinkDemand)]
   public static void Main()
   {
      try
      {
         // Create the 'IDictionary' to set the server object properties.
         IDictionary myDictionary = new Hashtable();
         myDictionary["name"] = "HttpClientChannel";
         myDictionary["priority"] = 2;
         // Set the properties along with the constructor.
         IChannelSender myIChannelSender = new HttpClientChannel(myDictionary,
                                    new BinaryClientFormatterSinkProvider());
         // Register the server channel.
         ChannelServices.RegisterChannel(myIChannelSender);
         MyHelloServer myHelloServer1 = (MyHelloServer)Activator.GetObject(
                  typeof(MyHelloServer), "http://localhost:8085/SayHello");
         if (myHelloServer1 == null)
         {
            Console.WriteLine("Could not locate server");
         }
         else
         {
            Console.WriteLine(myHelloServer1.myHelloMethod("Client"));
            // Get the name of the channel.
            Console.WriteLine("Channel Name :" + myIChannelSender.ChannelName);
            // Get the channel priority.
            Console.WriteLine("ChannelPriority :" + 
                        myIChannelSender.ChannelPriority.ToString());
            string myString,myObjectURI1;
            Console.WriteLine("Parse :" + 
                myIChannelSender.Parse("http://localhost:8085/SayHello",out myString)
                + myString);
            // Get the channel message sink that delivers message to specified url.
            IMessageSink myIMessageSink = 
                  myIChannelSender.CreateMessageSink(
                  "http://localhost:8085/NewEndPoint", null,out myObjectURI1);
            Console.WriteLine("Channel message sink used :" + myIMessageSink.ToString());
            Console.WriteLine("URI of new channel message sink :" + myObjectURI1);
         }
      }
      catch(Exception ex)
      {
         Console.WriteLine("Following exception is raised on client side : " + ex.Message);
      }
   }
}
#using <mscorlib.dll>
#using <System.Runtime.Remoting.dll>
#using <System.dll>
#using <IChannelSender_Share.dll>
using namespace System;
using namespace System::Collections;
using namespace System::Runtime::Remoting;
using namespace System::Runtime::Remoting::Channels;
using namespace System::Runtime::Remoting::Messaging;
using namespace System::Runtime::Remoting::Channels::Http;

int main()
{
   try
   {
      // Create the 'IDictionary' to set the server object properties.
      IDictionary* myDictionary = new Hashtable();
      myDictionary->Item[S"name"] = S"HttpClientChannel";
      myDictionary->Item[S"priority"] = __box(2);
      // Set the properties along with the constructor.
      IChannelSender* myIChannelSender = new HttpClientChannel(myDictionary,
         new BinaryClientFormatterSinkProvider());
      // Register the server channel.
      ChannelServices::RegisterChannel(myIChannelSender);
      MyHelloServer* myHelloServer1 = dynamic_cast<MyHelloServer*>(Activator::GetObject(
         __typeof(MyHelloServer), S"http://localhost:8085/SayHello"));
      if (myHelloServer1 == 0)
      {
         Console::WriteLine(S"Could not locate server");
      }
      else
      {
         Console::WriteLine(myHelloServer1->myHelloMethod(S"Client"));
         // Get the name of the channel.
         Console::WriteLine(S"Channel Name :{0}", myIChannelSender->ChannelName);
         // Get the channel priority.
         Console::WriteLine(S"ChannelPriority :{0}", __box(myIChannelSender->ChannelPriority));
         String* myString;
         String* myObjectURI1;

         Console::WriteLine(S"Parse :{0}{1}", myIChannelSender->Parse(S"http://localhost:8085/SayHello", &myString), myString);
         // Get the channel message sink that delivers message to specified url.
         IMessageSink* myIMessageSink = 
            myIChannelSender->CreateMessageSink(
            S"http://localhost:8085/NewEndPoint", 0,&myObjectURI1);
         Console::WriteLine(S"Channel message sink used :{0}", myIMessageSink);
         Console::WriteLine(S"URI of new channel message sink :{0}", myObjectURI1);
      }
   }
   catch(Exception* ex)
   {
      Console::WriteLine(S"Following exception is raised on client side : {0}", ex->Message);
   }
}

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: