using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace Start
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string appPath = Application.StartupPath;
AppDomainSetup startSetup = new AppDomainSetup();
startSetup.ApplicationBase = @"F:/MyProjects/Update/Update/bin/Debug";
startSetup.ApplicationName = "AutoUpdate";
startSetup.PrivateBinPath = @"F:/MyProjects/Update/Update/bin/Debug";
AppDomain startDomain = AppDomain.CreateDomain("start", null, startSetup);
startDomain.ExecuteAssembly(startSetup.ApplicationBase+"//Update.exe");
AppDomain.Unload(startDomain);
try
{
AppDomain auditDomain = AppDomain.CreateDomain("AuditBuilder", null, startSetup);
auditDomain.ExecuteAssembly("AuditBuilder.exe");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
}
}
using System.Collections.Generic;
using System.Windows.Forms;
namespace Start
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string appPath = Application.StartupPath;
AppDomainSetup startSetup = new AppDomainSetup();
startSetup.ApplicationBase = @"F:/MyProjects/Update/Update/bin/Debug";
startSetup.ApplicationName = "AutoUpdate";
startSetup.PrivateBinPath = @"F:/MyProjects/Update/Update/bin/Debug";
AppDomain startDomain = AppDomain.CreateDomain("start", null, startSetup);
startDomain.ExecuteAssembly(startSetup.ApplicationBase+"//Update.exe");
AppDomain.Unload(startDomain);
try
{
AppDomain auditDomain = AppDomain.CreateDomain("AuditBuilder", null, startSetup);
auditDomain.ExecuteAssembly("AuditBuilder.exe");
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
}
}
本文介绍了一个使用 C# 实现的应用程序启动及自动更新流程。该流程包括了创建新的 AppDomain 来加载并执行更新程序,以及尝试加载审计构建程序。通过这种方式可以在不干扰现有运行环境的情况下完成应用的更新。

1084

被折叠的 条评论
为什么被折叠?



