How to update an assembly for a running c# process

2019-01-23 16:31发布

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.

To summarize; how can I update the code while the .exe is in use?

标签: c# deployment
8条回答
太酷不给撩
2楼-- · 2019-01-23 16:52

Just an idea: Try MEF and [Import["http://someRemoteResource"]]

查看更多
Rolldiameter
3楼-- · 2019-01-23 16:57

You can't update the assembly when it's in use. The best option for this type of situation is to make a small executable which does a shadow copy of your assemblies, and launches them from a new location.

This way, when the user launches the program, you can shadow copy (locally) from the deployment site, which can always be overwritten.

查看更多
登录 后发表回答