Hi
pl let me know where is the problem and appreciate your help. thanks
Program cs:
class Program
{
static void Main(string[] args)
{
ILog _log = LogManager.GetLogger(typeof(WorkLoadService));
try
{
XmlConfigurator.ConfigureAndWatch(
new FileInfo(".\\log4net.config"));
var host = HostFactory.New(x =>
{
//x.EnableDashboard();
x.Service<WorkLoadService>(s =>
{
s.SetServiceName("WorkLoadService");
s.ConstructUsing(name => new WorkLoadService());
s.WhenStarted(tc =>
{
XmlConfigurator.ConfigureAndWatch(
new FileInfo(".\\log4net.config"));
tc.Start();
});
s.WhenStopped(tc => tc.Stop());
});
x.RunAsLocalSystem();
x.StartAutomatically();
x.SetDescription("WorkLoadService Description");
x.SetDisplayName("WorkLoadService");
x.SetServiceName("WorkLoadService");
});
host.Run();
}
catch(Exception ex)
{
_log.Error(ex.Message);
_log.Info(ex.Message);
}
}
}
public class WorkLoadService
{
private Timer _timer = null;
readonly ILog _log = LogManager.GetLogger(typeof(WorkLoadService));
public WorkLoadService()
{
double interval = 10000; //TBD need to take from config file.
_timer = new Timer(interval);
_timer.Elapsed += new ElapsedEventHandler(OnTick);
}
protected virtual void OnTick(object sender, ElapsedEventArgs e)
{
_log.Debug("Tick:" + DateTime.Now.ToLongTimeString());
//using(Queueing queueing = new Queueing())
//{
// queueing.ProcessStart();
//}
}
public void Start()
{
_log.Info("WorkLoadService is Started");
_timer.AutoReset = true;
_timer.Enabled = true;
_timer.Start();
}
public void Stop()
{
_log.Info("WorkLoadService is Stopped");
_timer.AutoReset = false;
_timer.Enabled = false;
}
}
screen shot
event log:
|
|
|
Keywords |
0x80000000000000 | |
|
|
|
|
|
[
SystemTime] |
2016-05-15T00:59:36.000000000Z | |
|
|
|
Application:
ICS.MDE.Win.WorkLoad.exe Framework Version: v4.0.30319 Description: The process
was terminated due to an unhandled exception. Exception Info:
System.NullReferenceException at
Topshelf.WindowsServiceCode.HostInstaller.Install(System.Collections.IDictionary)
at
System.Configuration.Install.Installer.Install(System.Collections.IDictionary)
at
System.Configuration.Install.TransactedInstaller.Install(System.Collections.IDictionary)
Exception Info: System.InvalidOperationException at
System.Configuration.Install.TransactedInstaller.Install(System.Collections.IDictionary)
at
Topshelf.Hosts.InstallHost.<Run>b__6(System.Configuration.Install.TransactedInstaller)
at
Topshelf.Hosts.AbstractInstallerHost.WithInstaller(System.Action`1<System.Configuration.Install.TransactedInstaller>)
at Topshelf.Hosts.InstallHost.Run() at
ICS.MDE.Win.WorkLoad.Program.Main(System.String[])
|
|
|
|
|
[
Name] |
Application
Error | |
|
|
|
Keywords |
0x80000000000000 | |
|
|
|
|
|
[
SystemTime] |
2016-05-15T00:59:37.000000000Z | |
|
|
|
C:\Development\CareNet\SourceCode\Windows
Service\WorkLoad\ICS.MDE.Win.WorkLoad\bin\Debug\ICS.MDE.Win.WorkLoad.exe |
|
|
|
C:\Windows\syswow64\KERNELBASE.dll |
|
|
|
4b44d29d-1a38-11e6-82b3-00607349ee54 | |