如何为正在运行的 c# 进程(又名热部署)更新程序集? [英] How to update an assembly for a running c# process (AKA hot deploy)?

查看:12
本文介绍了如何为正在运行的 c# 进程(又名热部署)更新程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .exe 程序集和一组引用程序集,我希望能够为其部署更新的代码.我实际上不需要更改正在运行的代码,但是下次我启动可执行文件时,我希望它获取更新的代码.目前,当我尝试复制正在运行的文件时,我收到有关另一个进程正在使用 .exe 的错误.

I have a .exe assembly and a set of referenced assemblies that I would like to be able to deploy updated code for. I don't need to actually change the running code, but the next time I launch the executable I would want it to pick up the updated code. Currently when I attempt to copy over the running file I get an error about the .exe being used by another process.

总结;在使用 .exe 时如何更新代码?

推荐答案

很容易做到.您可以重命名文件,Windows 锁定了句柄,而不是文件的目录条目.现在您可以毫无问题地复制更新.剩下要做的就是在您的应用程序再次启动后删除重命名的文件.如有必要.

It is easy to do. You can rename the file, Windows has a lock on the handle, not the directory entry for the file. Now you can just copy the update without problems. All that's left to do is to get rid of the renamed file after your app starts up again. If necessary.

这篇关于如何为正在运行的 c# 进程(又名热部署)更新程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆