简体   繁体   English

c#shadowcopy示例

[英]c# shadowcopy example

I need to update my executable with also the dll linked.. 我需要更新我的可执行文件也与dll链接..

I've read about the AppDomainSetup.ShadowCopyFiles but I'm in trouble trying the right steps to do what I need 我已经阅读了有关AppDomainSetup.ShadowCopyFiles但我在尝试正确的步骤来做我需要的东西时遇到了麻烦

the question are: 问题是:

  • the shadow copy I need to create only when I notify an update or each time I launch my executable? 我只有在通知更新或每次启动可执行文件时才需要创建的卷影副本?
  • what is the right step to copy and update the dlls and the .exe? 复制和更新dll和.exe的正确步骤是什么?

Creating a shadow copy is not going to update your application. 创建卷影副本不会更新您的应用程序。 The general sequence of auto-updating requires a third application that manages the process. 自动更新的一般顺序需要第三个管理该过程的应用程序。 It looks something like this. 它看起来像这样。

  1. Main application finds update and downloads update files to temp location 主应用程序查找更新并将更新文件下载到临时位置
  2. Main application launches updater application and terminates itself 主应用程序启动更新程序应用程序并终止自身
  3. Updater application copies update files over main application files Updater应用程序通过主应用程序文件复制更新文件
  4. Updater application launches main application and terminates itself Updater应用程序启动主应用程序并终止自身

Obviously there is going to be error handling logic built in to this. 显然,内置错误处理逻辑。 But that is the general idea. 但这是一般的想法。 Shadow copies are nowhere in there. 影子副本无处可去。

Making use of the shadow copy feature of .NET is not a bad idea. 利用.NET的卷影复制功能并不是一个坏主意。 It will allow you to update your assemblies without having to exit the application BUT you will need to restart the application in order to run the updated version. 它允许您更新程序集而无需退出应用程序但是您需要重新启动应用程序才能运行更新的版本。 Shadow copy will simply allow you to overwrite the assemblies and nothing else. 卷影副本只允许您覆盖程序集而不会覆盖任何其他内容。

Note that you cannot enable shadow copy on the default AppDomain . 请注意,您无法在默认AppDomain上启用卷影副本。 This means that you will need a loader that will create the AppDomain , and execute your application. 这意味着您将需要一个将创建AppDomain的加载器,并执行您的应用程序。 Have a look at this answer for the steps you need to take and for a simple implementation. 请查看此答案 ,了解您需要采取的步骤以及简单的实施步骤。

If all you want to do is allow updates to be installed without having to exit the application then this is the simplest approach I can think of. 如果你想要做的就是允许安装更新而不必退出应用程序,那么这是我能想到的最简单的方法。

You should also have a look at Microsoft's ClickOnce technology. 您还应该了解Microsoft的ClickOnce技术。 It solves a lot of the common problems of deploying and updating .NET GUI applications. 它解决了部署和更新.NET GUI应用程序的许多常见问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM