public IPCServiceConn(oVpnConnetion oVpnConnetion) { this.oVpnConnetion = oVpnConnetion; ServiceImplementation.conn = this; oVpnConnetion.onState += oVpnConnetion_onState; host = new ServiceHost(typeof(ServiceImplementation), new Uri(@"net.pipe://localhost/netfree-anywhere/")); host.AddServiceEndpoint(typeof(INfaServiceNotify), new NetNamedPipeBinding(), "control"); host.Open(); }
static void Main(string[] args) { if (!Environment.UserInteractive) { var ind = new ServiceS(); ServiceBase.Run(ind); } else { oVpnConnetion vpn = new oVpnConnetion(); Console.Read(); vpn.Disconnect(); } }
protected override void OnStart(string[] args) { Trace.WriteLine("start service OnStartPoint"); base.OnStart(args); try { Trace.WriteLine("start the interface check"); vpn = new oVpnConnetion(); } catch (Exception ex) { Trace.TraceError("filed to create interface check instance. the error:\n" + ex.ToString()); Stop(); } }