private void Reconnect_Click(object sender, RoutedEventArgs e) { try { if (_fileClient.State == CommunicationState.Opened || _fileClient.State == CommunicationState.Created) { _fileClient.Close(); } if (_dataClient.State == CommunicationState.Opened || _dataClient.State == CommunicationState.Created) { _dataClient.Close(); } _dataClient = new DataOperationClient("NetTcpBinding_IDataOperation"); _fileClient = new FileOperationClient("NetTcpBinding_IFileOperation"); FullArrayOfOsoba = _fileClient.GetDataFromXML().ToList(); list_osoba.ItemsSource = FullArrayOfOsoba; MessageBox.Show("There is a connection.", "Message"); } catch { MessageBox.Show("No connection to the service.", "Message"); } }
public MainWindow() { InitializeComponent(); try { _dataClient = new DataOperationClient("NetTcpBinding_IDataOperation"); _fileClient = new FileOperationClient("NetTcpBinding_IFileOperation"); FullArrayOfOsoba = _fileClient.GetDataFromXML().ToList(); list_osoba.ItemsSource = FullArrayOfOsoba; } catch { MessageBox.Show("No connection to the service.", "Message"); } }