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)

'Declaration
<ComVisibleAttribute(True)> _
Public Interface IChannelSender _
	Inherits IChannel
'Usage
Dim instance As IChannelSender

The sending side of channels must expose the IChannelSender interface.

Imports System
Imports System.Collections
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Messaging
Imports System.Runtime.Remoting.Channels.Http
Imports System.Security.Permissions

Public Class MyClient
   <PermissionSet(SecurityAction.LinkDemand)> _
   Public Shared Sub Main()
      Try 
         ' Create the 'IDictionary' to set the server object properties. 
         Dim myDictionary As New Hashtable()
         myDictionary("name") = "HttpClientChannel"
         myDictionary("priority") = 2
         ' Set the properties along with the constructor. 
         Dim myIChannelSender As New HttpClientChannel(myDictionary, _
                 New BinaryClientFormatterSinkProvider())
         ' Register the server channel.
         ChannelServices.RegisterChannel(myIChannelSender)
         Dim myHelloServer1 As MyHelloServer = CType(Activator.GetObject(GetType(MyHelloServer), _
                 "http://localhost:8085/SayHello"), MyHelloServer)
         If myHelloServer1 Is Nothing Then
            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())
            Dim myString As String = "" 
            Dim myObjectURI1 As String = ""
            Console.WriteLine("Parse :" + myIChannelSender.Parse("http://localhost:8085/SayHello", _
                 myString) + myString)
            ' Get the channel message sink that delivers message to specified url. 
            Dim myIMessageSink As IMessageSink = _
                 myIChannelSender.CreateMessageSink("http://localhost:8085/NewEndPoint", _
                 Nothing, myObjectURI1)
            Console.WriteLine("Channel message sink used :" + CType(myIMessageSink,Object).ToString())
            Console.WriteLine("URI of new channel message sink :" + myObjectURI1)
         End If 
      Catch ex As Exception
         Console.WriteLine("Following exception is raised on client side : " + ex.Message)
      End Try 
   End Sub 'Main
End Class 'MyClient
#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: