private void Authenticate_Command(object obj) { try { if (GetPasswordToViewModel != null) { GetPasswordToViewModel(null, null); } ILoginService contactMgmt = new AppLoginManager(); LoginInfo login = new LoginInfo(LoginName, Password); var returnValue = contactMgmt.ValidateLogin(login); if (!returnValue) { MessageBox.Show("Invalid login name / password, please try again.", "Contact Manager Sign In", MessageBoxButton.OK, MessageBoxImage.Error); } else { ObjectCache cache = MemoryCache.Default; CacheItemPolicy cacheItemPolicy = new CacheItemPolicy { AbsoluteExpiration = DateTime.Now.AddHours(1.0) }; cache.Add(CACHE_KEY, login, cacheItemPolicy); var mainWindow = new MainWindow(); if (CloseWindow != null) { CloseWindow(null, null); } mainWindow.ShowDialog(); } } catch (FaultException <CustomException> ex) { LogHelper.Log(LogType.Error, String.Concat(ex.Message, Environment.NewLine, ex.StackTrace)); MessageBox.Show(ex.Message, "Exception"); } catch (Exception exception) { LogHelper.Log(LogType.Error, String.Concat(exception.Message, Environment.NewLine, exception.StackTrace)); MessageBox.Show(exception.Message, "Exception"); } }