This has been replaced by Topshelf
Because a move to message based systems tends to spawn many independent services its necessary to make this process as easy as possible. So the 'Host' stuff lets us run a process as a windows service, as a console application, and a windows forms application. In the thread 'make it easy', we decided that instead of using a tool like 'InstallUtil' that you have to run outside of Visual Studio, we would make it so that you could simply add a console application to your project and then set up the host in there. Then debugging your application would be made much simpler.
Everything in host centers around the 'Runner.' The 'Runner' is a static class that is your entry point to the host process. You simply provide the runner with security credentials, some simple win service settings (service name, display name, and description) and then the usual start/stop semantics.
public class Program
{
public static void Main(string[] args)
{
var ioc_container = new YourContainer();
//traditianal ioc setup
var credentials = Credentials.LocalSystem;
var settings = WinServiceSettings.Custom("service name", "display name", "description")
var lifecycle = YourApplicationLifecycle();
Runner.Run(credentials, settings, lifecycle, args);
}
}
Now you can run this at the commandline like so:
| Action |
Commandline |
| Run as Console |
program.exe /console (the default as well) |
| Install as a Win Service |
program.exe /install |
| Uninstall as a Win Service |
program.exe /uninstall |
| Run as a service (once installed) |
program.exe /service |
| Run as a WinForm |
program.exe /gui (starts your program by looking for a 'Form' registered under the name 'host.startup') |
As we continue to make this a simpler process we can continue to update this sample. Also if you have any ideas to make it simpler, please let us know.
Comments (0)
You don't have permission to comment on this page.