Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > BOOK: Professional C#, 2nd and 3rd Editions
| Search | Today's Posts | Mark Forums Read
BOOK: Professional C#, 2nd and 3rd Editions
This is the forum to discuss the Wrox book Professional C#, 3rd Edition by Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen; ISBN: 9780764557590
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C#, 2nd and 3rd Editions section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 25th, 2006, 01:30 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default RegisterChannel on the client (.NET Remoting)

Hi. I'm working through the .NET Remoting chapter of the book, and I have a question. Any help would be appreciated. The following code (taken from the downloaded source code) is from the HelloClient.cs file (I deleted a few commented lines):

using System;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Activation;
using System.Runtime.Remoting.Lifetime;

namespace Wrox.ProCSharp.Remoting
{
   public class HelloClient
   {
      public static void Main(string[] args)
      {
         ChannelServices.RegisterChannel(new TcpChannel());
         object[] attrs =
            {new UrlAttribute("tcp://localhost:8086/Hello") };
      Hello obj = (Hello)Activator.CreateInstance(typeof(Hello),
               null, attrs);

    ILease lease = (ILease)obj.GetLifetimeService();
    if (lease != null)
    {
        Console.WriteLine("Lease Configuration:");
        Console.WriteLine("InitialLeaseTime: " +
                lease.InitialLeaseTime);
        Console.WriteLine("RenewOnCallTime: " +
        lease.RenewOnCallTime);
        Console.WriteLine("SponsorshipTimeout: " +
        lease.SponsorshipTimeout);
        Console.WriteLine(lease.CurrentLeaseTime);
    }

    MySerialized ser = obj.GetMySerialized();
    if (!RemotingServices.IsTransparentProxy(ser))
    {
       Console.WriteLine("ser is not a transparent proxy");
    }
    ser.Foo();
    MyRemote rem = obj.GetMyRemote();
    if (RemotingServices.IsTransparentProxy(rem))
    {
        Console.WriteLine("rem is a transparent proxy");
    }

    rem.Foo();

    System.Console.ReadLine();
    }
  }
}

I executed the sample and everything worked as expected, the server was active, the remote methods were called. So my question is: what's the need for the following line:

      ChannelServices.RegisterChannel(new TcpChannel());

I tried commenting it and everything worked exctly the same way! I see a need for registering a channel for the TCP client but no handle to it seems to be given by the previous code. Can anyone explain this to me?

Thanks in advance,
Miguel Barrosa

  #2 (permalink)  
Old January 25th, 2006, 01:37 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, I forgot to mention this. The previous post refers to the 3rd edition of the book.



Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Remoting premalm ASP.NET 2.0 Professional 3 August 5th, 2008 02:31 PM
.NET Remoting Client... babloo81 BOOK: Professional C#, 2nd and 3rd Editions 0 January 31st, 2006 02:31 AM
.NET Remoting application in vb.net Tek4VB .NET Web Services 6 November 19th, 2003 09:59 AM
Remoting (.Net) Indian Ocean .NET Web Services 6 November 12th, 2003 03:27 PM
.NET Enterprise Development in VB.NET Remoting burkert All Other Wrox Books 0 June 24th, 2003 09:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.