How To Debug Windows Service Without Installing
Debug Windows Service In C# Without Installing
This blog article is to prove how to Debug Windows Service without installing. When you lot create a Windows Service. Y'all should run across the lawmaking similar to the ane below but without the WriteLog.
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
WriteLog();
}
protected override void OnStop()
{
}
}
The original generated Main() is like the one beneath.
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
}
To debug without installing, add the lawmaking every bit follow, mainly #if (!DEBUG) .
static void Primary()
{
#if (!DEBUG)
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
#else
Service1 myServ = new Service1();
myServ.WriteLog();
0 Response to "How To Debug Windows Service Without Installing"
Post a Comment