home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / HelloGetObject2_cs_1________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-03-21  |  2.1 KB  |  58 lines

  1. /*=====================================================================
  2.  
  3.   File:      HelloGetObject2.cs
  4.  
  5. ---------------------------------------------------------------------
  6. This file is part of the Microsoft .NET Framework SDK Code Samples.
  7.  
  8.   Copyright (C) Microsoft Corporation.  All rights reserved.
  9.  
  10. This source code is intended only as a supplement to Microsoft
  11. Development Tools and/or on-line documentation.  See these other
  12. materials for detailed information regarding Microsoft code samples.
  13.  
  14. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  15. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  16. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  17. PARTICULAR PURPOSE.
  18. =====================================================================*/
  19.  
  20. using System;
  21. using System.Runtime.Remoting;
  22. using System.Runtime.Remoting.Channels;
  23. using System.Runtime.Remoting.Channels.Http;
  24.  
  25. using Hello;
  26.  
  27. public class HelloNew
  28. {
  29.     public static void Main(String[] args)
  30.     {
  31.         Console.WriteLine(".NET Remoting Sample - HelloGetObject2");
  32.         Console.WriteLine("--------------------------------------\n");
  33.  
  34.         String name = "Bill";    
  35.         Type type = typeof(HelloService);
  36.         String url = "http://localhost:8000/RemotingHello/HelloService.soap";
  37.  
  38.         Console.WriteLine("Loading HttpChannel");
  39.         ChannelServices.RegisterChannel(new HttpChannel());
  40.  
  41.         Console.WriteLine("Obtaining Proxy for HelloService, using Activator.GetObject");
  42.         HelloService helloService = (HelloService)Activator.GetObject(type, url);
  43.  
  44.         Console.WriteLine("Checking if helloservice is really a proxy");
  45.         if (RemotingServices.IsTransparentProxy(helloService) == true)
  46.             Console.WriteLine("helloService is a proxy!");
  47.         else
  48.             throw new Exception("helloService is not a proxy");
  49.  
  50.         Console.WriteLine("Calling HelloService.ReturnGreeting({0})", name);
  51.         String greeting = helloService.ReturnGreeting(name);
  52.  
  53.         Console.WriteLine("HelloService.ReturnGreeting returned: {0}", greeting);
  54.     }
  55. }
  56.  
  57.  
  58.