I have created a function to send message via MSMQ but getting exception while executing. below is my function.
public void SendMessageToQueue(ChessQueue chessQueue)
{
MessageQueue queue = null;
Message m = null;
if (!MessageQueue.Exists(".\\Private$\\" + chessQueue.QueueName))
{
queue = new MessageQueue(".\\Private$\\chessqueue");
chessQueue.Messages = new List<MessageObject>();
chessQueue.Messages.Add(chessQueue.Message);
queue.Formatter = new BinaryMessageFormatter();
m = new Message();
m.Body = chessQueue;
}
else
{
queue = new MessageQueue(".\\Private$\\" + chessQueue.QueueName);
queue.Formatter = new BinaryMessageFormatter();
m = queue.Receive();
ChessQueue ExistingChessQueue = m.Body as ChessQueue;
ExistingChessQueue.Messages.Add(chessQueue.Message);
m.Body = ExistingChessQueue;
}
queue.Send(m);
// Getting Exception at this Line
}
Exception:- The queue does not exist or you do not have sufficient permissions to perform the operation.
Also I'm unable to open security tab of Messaging Queue under Computer Management. See attached screenshot.
I tried creating the message queue under private manually and system allowed me to do so. See below
Below is the mmc span in.