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

  1. /*=====================================================================
  2.  
  3.   File:      HelloNew3.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 - HelloNew3");
  32.         Console.WriteLine("--------------------------------\n");
  33.         String name = "Bill";
  34.         String configFilename = "HelloNew3.exe.config";
  35.         Type type = typeof(HelloService);
  36.         String url = "http://localhost:8000/RemotingHello/HelloService.soap";
  37.  
  38.         Console.WriteLine("Configuring Remoting from {0}", configFilename);
  39.         RemotingConfiguration.Configure(configFilename);
  40.  
  41.         Console.WriteLine("Loading HttpChannel");
  42.         ChannelServices.RegisterChannel(new HttpChannel());
  43.  
  44.         Console.WriteLine("Configuring HelloService as WellKnown Client Type");
  45.         RemotingConfiguration.RegisterWellKnownClientType(type, url);
  46.  
  47.         Console.WriteLine("Obtaining Proxy for HelloService, using new");
  48.         HelloService helloService = new HelloService();
  49.  
  50.         Console.WriteLine("Checking if helloservice is really a proxy");
  51.         if (RemotingServices.IsTransparentProxy(helloService) == true)
  52.             Console.WriteLine("helloService is a proxy!");
  53.         else
  54.             throw   new Exception("helloService is not a proxy");
  55.  
  56.         Console.WriteLine("Calling HelloService.ReturnGreeting({0})", name);
  57.         String greeting = helloService.ReturnGreeting(name);
  58.  
  59.         Console.WriteLine("HelloService.ReturnGreeting returned: {0}", greeting);
  60.     }
  61. }
  62.