I want to make an extensible Windows service, which, when it starts, dynamically loads Dll.

Each Dll will be a specific task that should be performed on a schedule.

There are the following questions:

  1. Who better to give responsibility for the execution of the task on a schedule for the service itself or the object of the task?
  2. Is it correct to put the configuration of tasks into a separate XML file, and in app.config to store the address of this file, and then transfer it to the designers of the desired task, so that the object would search for itself and configure it?
  3. Will it be possible to replace extension libraries (for example, with an updated version) on the go without disconnecting or will they not allow me to replace the used libraries?
  4. Does it make sense to use MEF?

    1 answer 1

    1. Who better to give responsibility for the execution of the task on a schedule for the service itself or the object of the task?

    If all extensions are tasks, then it makes sense to put the task scheduler code in the main service, at least in order not to duplicate it in each extension.

    1. Is it correct to put the configuration of tasks into a separate XML file, and in app.config to store the address of this file, and then transfer it to the designers of the desired task, so that the object would search for itself and configure it?

    I would make the storage of settings in separate files for each job in a fixed folder or database and pass the parameters to the designer. But you can use your option. In any case, the extension should be able to handle the situation when it is added, but the configuration is missing.

    1. Will it be possible to replace extension libraries (for example, with an updated version) on the go without disconnecting or will they not allow me to replace the used libraries?

    A build loaded into the CLR can only be unloaded along with the domain to which it is loaded. This is solved by loading the extension builds into a separate AppDomain , and unloading this isolated domain, before removing the DLL. In general, it is better to ask a separate question about this mechanism, there are many nuances that need to be taken into account.

    1. Does it make sense to use MEF?

    Yes, this mechanism is intended for such cases.

    • was late with writing: (+1 - Shakra