/Overthere/RemoteConsole/Program.cs
C# | 42 lines | 36 code | 5 blank | 1 comment | 0 complexity | 5e6632e6b943dbd7766e588997b462ea MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.ServiceModel;
- using System.ServiceModel.Description;
- using System.Security.Principal;
-
- namespace RemoteConsole
- {
- class Program
- {
- static void Main(string[] args)
- {
- AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
-
- ServiceHost host = new ServiceHost(typeof(RemoteConsoleService));
- try
- {
- host.AddServiceEndpoint(typeof(IRemoteConsoleService), new NetTcpBinding(), "net.tcp://localhost:4005/Overthere");
-
- // HTTP is only necessary for service discovery
- ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
- smb.HttpGetUrl = new Uri("http://localhost:4006/Overthere");
- smb.HttpGetEnabled = true;
- host.Description.Behaviors.Add(smb);
-
- host.Open();
- Console.WriteLine("Running remote console... Press Enter to close.");
- Console.ReadLine();
-
- host.Close();
- }
- catch (CommunicationException ex)
- {
- Console.WriteLine(ex.ToString());
- host.Abort();
- Console.Read();
- }
- }
- }
- }