I have a basic task framework, where task such as doing some content processing, report generation, error log watcher, mailer, etc., is encapsulated in an ITask interface, which has a Run method, and other status related members. These tasks are either run continuously on a schedule, or on demand. They are hosted either as a windows service, or as a console application on a worker machine. The host application has runs a set of tasks with a TaskRunner class, which may use a schedule, threading, etc. I would like to be able to deploy a task to a worker machine in a more automated way than performing a release and doing an update. Basically, I would like to be able to send a process and implementation of an ITask interface (or another sub-component) to be run on some schedule, or with some settings. I know that I can load assemblies dynamically, and I have also seen: MEF. What is the best way to go about this? Should I build an implementation and publish the DLLs to a known directory where the worker process can read them? Should I publish the DLL as a binary to a database, for the worker to read?
Either way will work. It seems to me the one you prefer will depend on your operational requirements.
If you have a good database installed already, and you would like the tasks to be tightly managed and queryable, and if you have a number of other attributes that you would like to associate to a task, then a database, with its ability to enforce a strict schema and query/update capability will be the thing.
If instead you have a looser environment, you have no db server installed, and you just want to be able to push tasks out, a shared filesystem or just a file drop would make more sense.
If you don't see a strong preference for either, and if you want flexibility in the model, encapsulate the publish and load stuff, on either end, so that you can easily configure either a filesystem or a database, or some other provider.
In either case, loading the assembly dynamically and calling into it will be easy.
My recommendation would be to look at the WPF CAB project on Codeplex. Within the project it has the concept of registering new dlls as Modules which implement an interface IModule.
You could follow the same pattern only use ITask and then call the ITask.RunTask() or equivalent.