public App()
{
if (App.Current.InstallState == InstallState.Installed)
{
App.Current.CheckAndDownloadUpdateCompleted += OnCheckAndDownloadUpdateCompleted;
App.Current.CheckAndDownloadUpdateAsync();
}
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
new Login().Show();
}
/// <summary>
/// 自动更新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnCheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
if (e.UpdateAvailable && e.Error == null)
{
MessageBox.Show("应用新版本已经下载成功,将在下次启动时生效。");
}
else if (e.Error != null)
{
MessageBox.Show("在检测应用更新时, 在"
+ "出现以下错误信息:"
+ Environment.NewLine
+ Environment.NewLine
+ e.Error.Message);
}
}