public Form1() { InitializeComponent(); Create_New_Client(); try { client.Start(); } catch (Exception) { MessageBox.Show("Error while conntecting to the service, please restart the client."); client = null; Environment.Exit(0); } timer1.Interval = 100; timer1.Enabled = true; flowLayoutPanelReport.Size = new System.Drawing.Size(691, 417); flowLayoutPanelReport.Location = new System.Drawing.Point(297, 6); flowLayoutPanelReport.AutoScroll = true; flowLayoutPanelReport.Parent = tabPage2; }
private void Try_To_Create_New_Client() { try { NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport); binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; string uri = "net.tcp://localhost:9002/AntivirusService"; EndpointAddress endpoint = new EndpointAddress(new Uri(uri)); client = new AntivirusServiceClient(binding, endpoint); } catch (Exception) { MessageBox.Show("Error while creating new client (server might be stopped)."); client = null; } }