Avoir un service Windows qui écoute un msmq. Dans la méthode OnStart est cetteMessageQueue.BeginReceive() erreur de référence null - C#
protected override void OnStart(string[] args)
{
try
{
_queue = new MessageQueue(_qPath);//this part works as i had logging before and afer this call
//Add MSMQ Event
_queue.ReceiveCompleted += new ReceiveCompletedEventHandler(queue_ReceiveCompleted);//this part works as i had logging before and afer this call
_queue.BeginReceive();//This is where it is failing - get a null reference exception
}
catch(Exception ex)
{
EventLogger.LogEvent(EventSource, EventLogType, "OnStart" + _lineFeed +
ex.InnerException.ToString() + _lineFeed + ex.Message.ToString());
}
}
où
private MessageQueue _queue = null;
Cela fonctionne sur ma machine, mais lorsqu'il est déployé sur un serveur Windows 2003 et en cours d'exécution en tant que compte de service réseau, il ne
Exception recvd :
Service cannot be started. System.NullReferenceException: Object reference not set to an instance of an object.
at MYService.Service.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
Résolu: Problème avéré que le Q que j'ai mis en place, je devais explicitement ajouter le compte de service réseau sous l'onglet de sécurité
S'il vous plaît publier le contenu du 'Exception', y compris la trace de la pile. –