Updating application libraries (DLLs) at run time?

Is there a way to update the DLL when the application is running in C #? For example, if there is a DLL with a function that looks like this:

void write() { Console.WriteLine("LALALA"); } 

And it is called in a thread with 1 second between calls.

Now I wrote a new version:

 void write() { Console.WriteLine("LA LA LA\n"); } 

Can I update the old DLL with this new at runtime? It is important that my APP constantly works and does not work, but I think that updating libraries is an exception. I am wrong?

+4
source share
2 answers

If your code can be logically isolated in separate DLLs, you can use (as mentioned in other sources) a remote connection or System.AddIn. Depending on how integrated the functionality is, this may be too complex and / or excessive. One of the advantages of the System.AddIn method is that the assemblies can be unloaded, replacing the dll with a new version and reloading without stopping the application - it is intended only for lightweight plugin architectures, and the performance at the "isolation boundary" will be equal to as large .

Scripts can also be useful if the areas are small enough (something like http://www.ironpython.net/ ) - you can save the code in text files (or databases, or anywhere else) and load / run him from there. Then just replace the code and reload it.

I think it all comes down to whether it is possible to determine what can change, and if there is an isolation process that suits him. It is not easy to do this for the whole application!

+3
source

You cannot update the dll during use, but you can.

  • Make a copy of the dll with the new file name
  • Upload a copy of the dll to the application domain
  • Talk to this .net remote access application domain
  • When the original dll changes repeat above

This is what Asp.net does under the covers. So another option is to use Aps.net to host your application.

+3
source

All Articles