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