views:

30

answers:

2

I have a windows service which runs like a scheduler, it extends an interface which can be implemented by other classes to become plugin to this service. All plug-ins (eg Plugin1, Plugin2...) would be dropped in sub folder of PlugIn such as PlugIn\Plugin1, PlugIn\Plugin2 respectively. At runtime each of the subfolders (Plugin1, Plugin2) would be searched for any assembly implementing the interface and a timer would be scheduled with the corresponding dlls method.

Now in case Plugin1 & Plugin2 share a common.dll (private assembly) the scheduler loads it only once (whichever occured first). If for some business reasons we update common.dll for Plugin1 and copy it in Plugin1 folder, keeping Plugin2 with previous version, which becomes a problem because now common.dll would be loaded non deterministicaly.

Is there a way I could tie the set of binaries (from the respective folder) with the timer at the time of scheduling or later?

+3  A: 

It sounds to me like the thing to do here is to create an AppDomain per plugin / implementation, and use each plugins folder as the bin path. That way, each plugin can run with its own set of completely isolated assemblies.

The other (even more isolated) approach is to create a Process per call; that can be very effective and is simpler than handling AppDomains.

There is a vast range of info about working with AppDomains linked from here (see the table).

Marc Gravell
I have gone thru the Appdomain route, but wasn't able to restrict loading of the dll. I wanted to exploit the Process but couldn't conceve a way to acomplish it in this case where service code would create a new process everytime its introspecting and scheduling a method from a qualified dll.
After implementing this way (each plug-in is a new process under the host service) at runtime the common/shared dll from the Host location is getting loaded once per life cycle and not from the respective plug-in location for each plug-in.anything which might be faulty/I should consider in my implementation?
@rockvista - maybe the `PrivateBinPath` etc of the `AppDomainSetup`?
Marc Gravell
A: 

A simple solution would be to use ILMerge to merge all assemblies of a plugin into a single assembly. That should take care of it.

Treb
I have tried this with no luck, basically it creates a composite library/exe file at design time, which gets exploded by CLR at runtime and poses the same problem.Basically with a quick overview of ILMerge it seems like a ZIP tool to collate binaries.