I'm trying to have some kind of "auto-update" application. Idea is to have unchangeable code, which will reference a DLL, with all the logic contained in DLL. Basically, it will work by looking for updates every 5 minutes. If an update is available, the dispose method is called, disposing of everything from DLL, then downloading new DLL and referencing it, also running its start method afterward.
I have something like this:
var DLL = Assembly.LoadFile(path_to_appdata+"dll_name.dll");
runner_dll = DLL.GetType("dll_namespace_name.Manager");
var c = Activator.CreateInstance(runner_dll);
var method = runner_dll.GetMethod("run_client");
method.Invoke(c, new object[] { });
and it works. However, the thing is I can't update the DLL because it's in use. I've read that I can't remove it directly from Assembly, but I can load it in an AppDomain, then unload an AppDomain. However, I've tried to do it, but I don't seem to make it work.
Any help would be very appreciated.