title: How to get Windows Service and ASP.NET MVC project interacting?
body: <p>I've two separated projects being one of them a Windows Service having another one has a reference.</p>
  
  <p>I want my Service to call a method from the referenced project, something like this:</p>
  
  <pre><code>protected override void OnStart(string[] args) {
      MessageSystem msg_system = new MessageSystem();
  
      IQueryable&lt;MensagemGrupo&gt; mensagens = 
          msg_system.GetScheduledMensagensGrupo();
  
      foreach (var msg in mensagens) {
          msg_system.ConfirmaEnvio(DateTime.Now, msg.id);
      }
  </code></pre>
  
  <p>The code i'm invoking throw the Service:</p>
  
  <pre><code>public class MessageSystem {
      private StorageModelDataContext db = new StorageModelDataContext();
  
      public IQueryable&lt;MensagemGrupo&gt; GetScheduledMensagensGrupo() {
          IQueryable&lt;MensagemGrupo&gt; mensagens = db.GetMensagensGrupoAgendadas();
  
          return mensagens;
      }
  }
  </code></pre>
  
  <p>I'm getting a System.NullReferenceException starting at db.GetMensagensGrupoAgendadas(). Could it be because db is in a remote server?</p>
  
  <p>Can i call methods this way from the service?</p>
  
  <p>PS: The Service is LocalSystem. I've tried Network Service but i get "Error 5: Access Denied" while starting the service.</p>