private void Button_Click(object sender, RoutedEventArgs e) { if (oObservingConditions != null && oObservingConditions.Connected) { return; } try { observingConditionsID = ObservingConditions.Choose(observingConditionsID); oProfile.WriteValue(profileID, "observingsConditionID", observingConditionsID); } catch (Exception ex) { String msg = ex.Message; if (ex.InnerException != null) { msg += " - " + ex.InnerException.Message; } MessageBox.Show(string.Format("Choose failed with error {0}", msg)); } }