I create a simple window service, and when I go for debugging, I get an error: "Unable to evaluate the expression because its own frame is on top of the call stack." Also, when I create a service in Release and start it, it just freezes.
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new MyService1() };
ServiceBase.Run(ServicesToRun);
}
This is all that is in the Program.cs file, where it usually hangs on the ServiceBase.Run line (ServicesToRun).
All that I managed to find relates only to an expression that is not evaluated, because the code is optimized or deals with asp.net and response.redirect.
Code for the service.
public TruckRateClearService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
tmrProcess.Enabled = true;
}
protected override void OnCustomCommand(int command)
{
base.OnCustomCommand(command);
if (command == 129)
{
OnStart(null);
}
}
protected override void OnStop()
{
tmrProcess.Enabled = false;
}
private void tmrProcess_Tick(object sender, EventArgs e)
{
tmrProcess.Enabled = false;
try
{
eventLog.WriteEntry("Clearing Truck Rates Start" + DateTime.Now.ToString());
TruckRateClearingAgent.Process();
eventLog.WriteEntry("Clearing Truck Rates Finished" + DateTime.Now.ToString());
}
catch (Exception ex)
{
eventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
tmrProcess.Enabled = true;
}
internal void Run()
{
tmrProcess_Tick(tmrProcess, null);
}
Void Run() . , , .
Native , , 76F17094 ret. , , , - .
, VS, . - .exe, -.vshost.exe. , .exe Attach . - , v4 Framework (.vshost.exe-), - v2 (single.exe) Framework?
, . , , . , , System.Windows.Forms. System.Timers.Timers . VS , , Internal Run(). n.n