title: Cannot evaluate expression because a native frame is on top of the call stack
body: <p>I'm creating a simple window service and when I go to debug I get the error, "Cannot evaluate expression because a native frame is on top of the call stack.". Also, when I build the service in Release and run it just hangs.</p>
  
  <pre><code> static void Main()
      {
          ServiceBase[] ServicesToRun;
          ServicesToRun = new ServiceBase[] { new MyService1() };
  
          ServiceBase.Run(ServicesToRun);
      }
  </code></pre>
  
  <p>Thats all that is in the Program.cs file, where it normally gets hung on the ServiceBase.Run(ServicesToRun) line.</p>
  
  <p>Everything I've been able to find only relates to the expression not being evaluated because the code is optimized or having to deal with asp.net and response.redirect.</p>
  
  <p>Code for the Service.</p>
  
  <pre><code>    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);
      }
  </code></pre>
  
  <p>The Internal Void Run() was added just recent on the suggestion in the comments by Eren Ersönmez. His idea has been very helpful for helping debug my logic until I can figure the rest out.</p>
  
  <p>I was able to get the into the Native call stack and it sits on one location, 76F17094 ret. Now I have no idea what this is but maybe someone else will.</p>
  
  <p>Also, when I start the service and look into attaching it to VS I'm noticing two instances of it. One is the normal .exe and another is a .vshost.exe. When I start other services I only see the .exe file in the Attach to process part of the debugger. Could this be because one is on the v4 Framework ( .vshost .exe service ) and another on the v2 ( single .exe service ) Framework? </p>
  
  <p>I believe I got it working. It seems that the problem lied with the timer I was using. The original timer I was using was a System.Windows.Forms timer. I switched it to System.Timers.Timers and everything started working again. Still cant attach VS to it but I can debug it still by using the Internal Run() method. Thanks for all the help n.n</p>