To read article click HERE.
Thursday, June 18, 2009
Wednesday, June 17, 2009
Debug windows service
In the time, when you work on development a windows service not possible to debug it. A solution is a converting service to console application or creating additional service runner or anymore. I want to present very simple, effective and easy way how to resolve this. In debug mode will run application and in not debug mode will run service.
[RunInstaller(true)]
public partial class ServiceRunner : ServiceBase
{
[STAThread]
static void Main()
{
#if !DEBUG
//Run Windows Service
Run(new ServiceRunner());
#else
//Run Application
new YourServiceBody();
#endif
}
public ServiceRunner()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
new YourServiceBody();
}
protected override void OnStop()
{}
}
Good luck!
Subscribe to:
Posts (Atom)