To make service discoverable, implement ISelfHostingConfiguration inteface and mark class using ExportSelfHostingConfiguration attribute.

public class SelfHostingConfiguration : ISelfHostingConfiguration
    // implementation here

SelfHostingContainer will export marked configurations and instantiate service hosts for target services.

// create catalog and composition container
var catalog = new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory);
var container = new CompositionContainer(catalog);
using (var serviceContainer = new SelfHostingContainer(container))
    Console.WriteLine("Press RETURN to close hosts and exit...");

Last edited Jan 9, 2014 at 10:36 PM by kovalikp, version 3