private void GetZipCodesButton_Click(object sender, RoutedEventArgs e) { ZipCodesListBox.ItemsSource = null; ZipCodesListBox.Items.Clear(); ErrorMessage2TextBox.Text = ""; string state = StateTextBox.Text; // ReSharper disable once InvertIf if (state != "") { // Alternate constructor //EndpointAddress endpointAddress = new EndpointAddress("net.tcp://localhost:8009/GeoService"); //Binding binding = new NetTcpBinding(); //GeoClient geoClient = new GeoClient(binding, endpointAddress); List <ZipCodeData> zipCodeDataList = null; WcfBindingType wcfBindingType = GetBindingTypeFromRadioButtons(); GeoClient geoClient = GetGeoClientWithBinding(wcfBindingType); try { zipCodeDataList = geoClient.GetZipCodes(state); } catch (FaultException exception) { string message = "Exception: \r\n" + $"Message = {exception.Message} \r\n" + $"Proxy state = {geoClient.State.ToString()}"; ErrorMessage2TextBox.Text = message; } if (zipCodeDataList == null || zipCodeDataList.Count == 0) { ErrorMessage2TextBox.Text = $"No zip code data found for state {state}"; } ZipCodesListBox.ItemsSource = zipCodeDataList; geoClient.Close(); } }