PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Overthere/RemoteConsole/Program.cs

https://bitbucket.org/floAr/personal
C# | 42 lines | 36 code | 5 blank | 1 comment | 0 complexity | 5e6632e6b943dbd7766e588997b462ea MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ServiceModel;
  6. using System.ServiceModel.Description;
  7. using System.Security.Principal;
  8. namespace RemoteConsole
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
  15. ServiceHost host = new ServiceHost(typeof(RemoteConsoleService));
  16. try
  17. {
  18. host.AddServiceEndpoint(typeof(IRemoteConsoleService), new NetTcpBinding(), "net.tcp://localhost:4005/Overthere");
  19. // HTTP is only necessary for service discovery
  20. ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
  21. smb.HttpGetUrl = new Uri("http://localhost:4006/Overthere");
  22. smb.HttpGetEnabled = true;
  23. host.Description.Behaviors.Add(smb);
  24. host.Open();
  25. Console.WriteLine("Running remote console... Press Enter to close.");
  26. Console.ReadLine();
  27. host.Close();
  28. }
  29. catch (CommunicationException ex)
  30. {
  31. Console.WriteLine(ex.ToString());
  32. host.Abort();
  33. Console.Read();
  34. }
  35. }
  36. }
  37. }