views:

698

answers:

2

I'm looking for suggestions about how can I build an extensible WCF server (with dynamically loaded services), preferably using System.Addins or MEF.

The server should host any WCF service (contained in DLL assemblies, loaded in runtime) that implements a minimal "plugin" API (StartService/StopService/GetStatus?/etc).

This post is a good start. Some objectives and points to discuss:

  • Use/do not use an isolated AppDomain for each service?
  • How to configure each service (endpoints, transport protocols)? XML-config file or a better alternative?
  • Delayed/lazy load of assemblies (when a service request arrives)? Possible? Useful? How to?
  • Assembly reload when file on disk changes (useful for development environment);
  • Service restart when configuration on disk changes;

and, of course, other ideas are always welcome ;)

+5  A: 
  • Yes, use an isolated AppDomain for each service. You need AppDomain isolation so that you don't take down other services that are running in the event one goes down.

  • Offer all the ways WCF currently does, either through programming or through config. Programattic access is difficult, since the ServiceHost instance is not serializable, so getting the information across the app domain boundary is going to be a pain.

  • I would say it is possible to do. However, this basically is replicating Windows Process Activation Service, so you might want to begin to look there for your functionality.

  • It's helpful for development, but honestly, I don't think that it's that important a function to have. It complicates your code for a gain that isn't too measurable (IMO). I would rather write a script which will stop the service, copy the file, and restart it instead of overcomplicating the codebase and always having to watch the assembly.

  • Now you are talking about IIS. You can essentially have IIS host your service and it will recycle it when the config file changes.

All that being said, it seems that WAS and IIS offer you most of what you want (highly avaliable, isolated app domains, configuration, etc, etc), so you might want to ask why you would want to do this yourself.

casperOne
A: 

Here is a codeproject.com article with some of what I think you're trying to achieve.

kenny