I have a server-client application. Sometimes the server is updated which requires some DLLs in the client to be updated as well (The DLLs are the dependencies of the main executable). For now, we have to close the client, manually deploy the DLLs, and then start the client again. This is kind of an inconvenience because the client is an automated application, so normally it doesn't need any user intervention.

Is it possible for this to be done automatically without restart or user intervention? Like, the client would download the latest DLL, and replace the current one?

  • What about a solution which needs a restart of the application, but does not need any user intervention?
    – Doc Brown
    Oct 4, 2012 at 9:41
  • At the very least the application would have to restart in order for the dependent files to be updated. Since having the automated application randomly restarting when it wants to likely isn't a good idea manual intervention likely is best.
    – Ramhound
    Oct 4, 2012 at 12:15

3 Answers 3


This is an ordinary sandbox model (the one which is used with plugins/addins). Instead of calling the libraries directly, you load them in a different AppDomain. Doing this actually allows you to update the corresponding libraries while the application is still running.

If you want to automate the process, the client application can monitor the directory with those libraries, and load newer ones to the sandboxed AppDomain when they are available.

Note that:

  • Using sandbox is not as easy as not using it, and you must be ready to have some issues. The two I had were that I was unable to put the UI elements in the sandboxed libraries and that cache stopped working when using sandbox.

  • If there are lots of exchange between the sandbox and the application itself, you may see the performance of your application decrease.

  • With a sandbox, you will not be able to unload, update and load the updated version of the library if the application is running at the same moment the code from this library. It's just not possible, and doesn't make sense.

    This is probably also why the browsers like Chrome and Firefox still need to restart to finish the updates.

    If this is your case, you may search for a way to indicate to the code from the library that it must stop, since the library will be unloaded.

  • The overall architecture of your application would be more complex, for sure. Does it worth it? Couldn't you schedule a background update, i.e. every night, if a new version is available, the application will just stop entirely, update itself (through an updater executable), and then be restarted by the updater?

  • While I won't say its not possible to update a file already being used, I cannot think of a single example of it being done, and there are many reasons doing so is a horrible horrible idea. In other words the reasons Chrome and Firefox need to be restarted, is they have files in memory being used, and trying to update those files in memory would cause more problems then it would solve.
    – Ramhound
    Oct 4, 2012 at 12:17
  • @Ramhound: short example: imagine you have a background app which monitors a directory and when a file arrives in this directory, this daemon processes this file and removes it. The processing itself is done within a DLL. In that case, you can without any problem use the sandbox model to update the DLL while the app is not processing anything, i.e. the code in the DLL is not actually running. Oct 4, 2012 at 12:40

Yes, it is possible in many different ways. The easiest way is called ClickOnce Deployment.

This a very convenient deployment mechanism for smart client applications built for the .NET Framework. You may get detailed information on how to set your updates to be done automatically when your clients are starting. Here is a good reference on how to administrate the process - Administering ClickOnce Deployments.

  • You haven't read the question. It is not about the deployment, but about the ability to update the libraries without manually restarting the application which uses them. ClickOnce has nothing to do with that. Oct 4, 2012 at 2:52
  • 1
    @MainMa - ClickOnce is dirt simple to implement and it solves a lot more problems than it causes. I agree it doesn't meet the letter of the OP's requirements, but this is a case where a small change in the requirements could yield a big savings in implementation effort. As you noted, even the sandbox approach may still need to restart to finish the updates. Oct 4, 2012 at 3:01
  • @Dan Pichelman: "and it solves a lot more problems": but not the problem the OP is currently encountering. Yes, ClickOnce could be suggested in a comment, but it cannot be an answer. Oct 4, 2012 at 3:09

You should look into having your application implement MEF (Managed Extensibility Framework). With MEF you can easily load your DLL dependencies from a Directory Catalog, and write code to refresh the catalog when the directory contents change. This can all be done on the fly without the app having to be stopped and restarted, if done right.

It's not a code-free solution, though. You have to write the MEF functionality in your main app that loads the catalog, and the DLLs would have to be written to accommodate MEF.

  • Interesting.. How hard is the learning curve for MEF?
    – Louis Rhys
    Oct 4, 2012 at 6:38
  • I've done things similar to MEF using Web Services and/or reflection based dynamic loading on several projects. Having a standard framework around such functionality can help. I'm glad to see that it looks like some of the functionality is going directly into the Framework. That gives me a little more confidence that it will be around longer.
    – jfrankcarr
    Oct 4, 2012 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.