0

I have a windows service which calls WCF service hosted remotely at server for checking if new versions avilable or not, and it (windows service) references some DLLs, sometimes these DLLs is out of date and new DLL is generated (New DLL takes version id).

I need the windows service to stop itself, download new DLLs and replace referenced DLLs with new DLLs downloaded from server then start again (Inside event OnStart()).

How can i do that without creating new windows service to do that?

Thanks in advance.

Ahmy
  • 5,420
  • 8
  • 39
  • 50
  • You cannot do that with "statically" "linked" dlls. That's those you reference in your project. You will need to load your dll dynamically and since you cannot unload it dynamically, you will need to create a new appdomain for it so you can then drop the appdomain and create a new one when you need to. – nvoigt Jun 18 '14 at 12:24
  • A method often used to update running applications (think an app that checks for updates when you first launch it) is to include a small exe with your updater that shuts down the main app, updates the files and then re-launches the application. – Zippit Jun 18 '14 at 12:50
  • @ Zippit how can i call exe which will handle this scenario? i tried to call an exe from windows service which stops the service and download files then start it but faile – Ahmy Jun 18 '14 at 14:16
  • @Ahmy: services can launch other applications. If the other application fails to run, start by checking the error code returned by CreateProcess, or the exit code returned by the application itself (you can use GetExitCode to retrieve this). Might be a missing DLL dependency, for example, or you might not have specified the right path to the application. – Harry Johnston Jun 19 '14 at 05:11

0 Answers0