I want to consume msmq service. But unable to send message to queue. Here is my code.
System.Messaging.MessageQueue msmQ = new System.Messaging.MessageQueue("net.msmq://myServerName/private/MyQueueName");
msg ="<nodeDetails><node>Node1</node></nodeDetails>";//Dummy value. it is XML structure consist of multiple node
msmQ.Send(msg);
It gives me an error on msmQ.Send(msg)
Length cannot be less than zero. Parameter name: length
The following things are installed on my m/c:
- Microsoft Message Queue(MSMQ)Server
- Window Activation Process
Also when I tried as
bool msmQExits = MessageQueue.Exists("net.msmq://myServerName/private/MyQueueName");
it gives "Path syntax is invalid". I am not able to get anything on it.
I just have a msmq URL net.msmq://myServerName/private/MyQueueName.
How can I consume such URL and send my message to "MyQueueName"?
Change your queue name to this:
And you cannot check if a remote query exists by
MessageQueue.Existsmethod. It will always throw an exception.You can check these links for more info:
Also, the problem is not with the message you see that length is less than 0. If you go deeper and check the stack trace you’ll see that your queue name has an invalid format. It tries to find
FORMAToccurrence inside your queue name, doesn’t find it andSubstring()method returns-1there.Stacktrace: