MessageQueue.BeginReceive() null ref error - c#

Posted by ltech on Stack Overflow See other posts from Stack Overflow or by ltech
Published on 2010-04-13T15:41:07Z Indexed on 2010/04/13 15:43 UTC
Read the original article Hit count: 517

Filed under:

Have a windows service that listens to a msmq. In the OnStart method is have this

 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());
            }
        }

where

private MessageQueue _queue = null;

© Stack Overflow or respective owner

Related posts about c#