I have created a function to send message via MSMQ but getting exception while executing. below is my function.
public void SendMessageToQueue(ChessQueue che
if (!MessageQueue.Exists(".\\Private$\\" + chessQueue.QueueName))
{
queue = new MessageQueue(".\\Private$\\chessqueue");
// etc..
There are two bugs in this code. First problem is that it hard-codes the queue name in the string instead of using chessQueue.QueueName. A mismatch will be fatal of course. Second problem, and surely the most critical one, is that it doesn't actually create the queue. Proper code should resemble:
string name = ".\\Private$\\" + chessQueue.QueueName;
if (!MessageQueue.Exists(name))
{
queue = MessageQueue.Create(name);
// etc...
Looked like this after I ran this code, with one queue.Send() call: