private void ButtonStartProxy_Click(object sender, RoutedEventArgs e) { this.ButtonStartProxy.Visibility = Visibility.Hidden; IPAddress host = Dns.GetHostAddresses(Dns.GetHostName()).Where(ip => ip.AddressFamily == AddressFamily.InterNetwork && !ip.ToString().StartsWith("172")).FirstOrDefault(); SocketProxy proxy = new SocketProxy(host); proxy.SocketLog += Proxy_OnLog; try { int port = int.Parse(this.TextBoxPort.Text); proxy.InitializeServer(port); proxy.StartListening(); } catch (Exception ex) { proxy.Close(); //MessageBox.Show("Server window start listening error: " + ex.Message); Proxy_OnLog(this, new SocketLogEventArgs("Proxy window start listening error: " + ex.Message, LogLevel.Error)); } }