Is there a way to update DLL while application is running in C#? For example, if there is DLL with a function that looks like this:
void write()
{
Console.WriteLine("LALALA");
}
And it is called in a thread with 1 second sleep between calls.
Now, I wrote the new version:
void write()
{
Console.WriteLine("LA LA LA\n");
}
Can I update old DLL with this new one during runtime? It is important that my APP is up and running all the time, no meter what... but I guess that updating libraries is an exception. Am I wrong?
You cannot update a dll while it is in use, however you can.
This is what Asp.net does under the covers. So another option is to use Aps.net to host your app.
If your code can be logically isolated into seperate DLLs, you can use (as others have mentioned) remoting or the System.AddIn framework. Depending on how integrated the functionality is though, it may be far too complicated and/or overkill. One benefit of the System.AddIn method is that assemblies can be unloaded, the dll replaced with a new version, and reloaded again without stopping the app - it is only designed for lightweight plugin architectures though, and performance across the 'isolation boundary' isn't going to be as great.
Scripting may also be useful if the areas are small enough (something like http://www.ironpython.net/) - you can store the code in text files (or database, or wherever) and load/run it from there. Then just replace the code and reload it.
I guess it all comes down to whether you can identify what is likely to change, and if there is an isolation process that would suit it. To do it to the entire application isn't easy!