Unity - running Windows Service(s)

Jul 7, 2008 at 10:13 PM
 The following template is provided when creating a new Windows Service

static void Main()
{
    ServiceBase
[] ServicesToRun;
    ServicesToRun =
new ServiceBase[]
    {
        new DataGatewayService(new GatewayService())
    };
    ServiceBase.Run(ServicesToRun);
}

For now I'm going with the following code to launch my Windows Service (second service won't be required for a wee bit) but being new to Unity I'm not sure what the best way is to get an Array of ServiceBase[] to resolve....   In my ignorance I would opt to manually populate a Servicebase[] by iterating through the results of a ResolveAll(<ServiceBase>()) and passing it on to ServiceBase.Run().  

static
void Main()
{
    IUnityContainer container = new UnityContainer()
        .RegisterType<
ServiceBase, Service1>()
        .RegisterType<
ILogger, TraceLogger>()
        .RegisterType<
IImageProcessor, ImageProcessorService>();

    ServiceBase.Run(container.Resolve<ServiceBase>());
}

Is there a better way?