WmAutoUpdate - 有人用过吗?不会回滚

发布于 2024-10-10 09:31:46 字数 1000 浏览 0 评论 0原文

我构建了一个 Compact Framework 应用程序,并使用 WmAutoUpdate 将新版本部署到移动设备 (http://www.sebastianvogelsang.com/2009/09/23/wmautoupdate-a-net-compact-framework-auto-update-library/< /a>)。有人用过这个吗?这很酷,但我有一个问题。

如果我导致应用程序在更新过程中崩溃,则应该通过将备份版本复制回主目录来恢复。这不起作用,因为 exe 文件被操作系统“锁定”,因为它当前正在使用。我可以验证情况确实如此,因为我也无法使用 Windows 资源管理器删除它。错误详细信息是:

System.IO.IOException was unhandled
Message="IOException"
StackTrace:
     at System.IO.__Error.WinIOError(Int32 errorCode, String str)
     at System.IO.File.Move(String sourceFileName, String destFileName)
     at WmAutoUpdate.Updater.assertPreviousUpdate()
     at WmAutoUpdate.Updater..ctor(String url)

Updater.assertPreviousUpdate() 中的这一行发生错误:

File.Move(f, appPath + "\\" + getFilenameFromPath(f));

代码在允许正常运行时设法更新应用程序 exe 文件(我不确定如何)。问题是回滚时不起作用。

欢呼
标记

I've built a Compact Framework application and I'm using WmAutoUpdate to deploy new versions to the mobile devices (http://www.sebastianvogelsang.com/2009/09/23/wmautoupdate-a-net-compact-framework-auto-update-library/). Has anyone used this? It's cool but I've got a problem.

If I cause the application to crash half-way through updating it is supposed to recover by copying the backup version back into the main directory. This doesn't work because the exe file is "locked" by the operating system because it is currently in use. I can verify this is the case because I can't delete it using Windows Explorer either. The error details are:

System.IO.IOException was unhandled
Message="IOException"
StackTrace:
     at System.IO.__Error.WinIOError(Int32 errorCode, String str)
     at System.IO.File.Move(String sourceFileName, String destFileName)
     at WmAutoUpdate.Updater.assertPreviousUpdate()
     at WmAutoUpdate.Updater..ctor(String url)

The error occurs on this line in Updater.assertPreviousUpdate():

File.Move(f, appPath + "\\" + getFilenameFromPath(f));

The code manages to update the application exe file when it's allowed to run normally (I'm not sure how). The problem is that it doesn't work when rolling back.

Cheer
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱已欠费 2024-10-17 09:31:46

我使用过 WmAutoUpdate 并且发现了同样的问题。问题是您可以移动实际运行进程的文件,但不能覆盖它们。如果您检查更新部分,WmAutoUpdate会将正在运行的应用程序移动到备份目录,然后将更新版本写入原始目录。我已经通过这种方式修复了回滚部分:

if (Directory.Exists(backupDir))
{
  string tmpDir = Path.Combine(Path.GetTempPath(),Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
  Directory.Move(appPath, tmpDir);
  Directory.Move(backupDir, appPath);
}

首先,我们将正在运行的应用程序文件移动到 Temp 中的随机目录。然后我们将备份文件夹复制到应用程序原始目录中。当然,这会在设备的 Temp 目录中生成一个 .TMP 文件,以及一个包含实际运行进程的文件夹。您必须在生产代码中偶尔删除此临时文件夹。

I've used WmAutoUpdate and I've found the same problem. The issue is that you can move the files of the actual running process, but you cannot overwrite them. If you check the update part, WmAutoUpdate moves the running application to a backup directory and then it writes the update version to the original directory. I have fixed the rollback part this way:

if (Directory.Exists(backupDir))
{
  string tmpDir = Path.Combine(Path.GetTempPath(),Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
  Directory.Move(appPath, tmpDir);
  Directory.Move(backupDir, appPath);
}

First we move the running application files to a random directory in Temp. Then we copy the backup folder to the application original directory. Of course, this will generate a .TMP file in the Temp directory of your device, and a folder with the actual running process. You will have to delete this temporary folder once in a while in production code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文