c# on windows updating a program while it's still running

流过昼夜 提交于 2019-12-23 04:33:55

问题


I have a program on a kiosk with an associated service that updates the program by periodically checking on the web for a newer version of the MSI. If it finds one, it will install it, the program may still be running.

To get around the DLL conflicts of the above solution, I rename the assemblies in the MSI with by version so a new version can install while the old is running. The application will poll the install directory for newer version assemblies and if it finds one restart as soon as it is not being used. Are there any better ways to do this?


回答1:


I've done this story before. It works like this:

The UI is running as the logged on User.

The service is running as System. The service checks for content and downloads it to a temp directory. It then advertises the MSI using the /JM command. The installer can now be installed by the non-priviledged user.

The service sends an IPC message to the application saying that it's time to install. The application kicks off the installer passing it a flag that indicates to restart the application. The application the quits releasing the locked files.

At the end of the installer the flag causes the installer to relaunch the application.

Also take a look at the wuw4 library. It helps in creating a lot of this solution.




回答2:


Wouldn't ClickOnce be a better option here?

http://msdn.microsoft.com/en-us/library/t71a733d.aspx



来源:https://stackoverflow.com/questions/8984460/c-sharp-on-windows-updating-a-program-while-its-still-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!