0

I am able to send the messages to the MSMQ through private queue.

C#

   var queue = new MessageQueue(@"FormatName:DIRECT=OS:machinename\myqueue");
   queue.Send(myMessage, MessageQueueTransactionType.Single);

enter image description here

But when I am trying to send the MSMQ messages through public queue.

C#

   var queue = new MessageQueue(@"FormatName:DIRECT=OS:machinename\PUBLIC$\myqueue");
   queue.Send(myMessage, MessageQueueTransactionType.Single);

I am getting the following error message:

Format name is invalid

Please assist in resolving the issue.

Pearl
  • 8,373
  • 8
  • 40
  • 59

1 Answers1

2

According to the MSDN docs here ...

https://msdn.microsoft.com/en-us/library/ch1d814t(v=vs.110).aspx

It looks like you don't need "PUBLIC$" in the path for public queues.

So perhaps something like ...

var queue = new MessageQueue(@"FormatName:DIRECT=OS:machinename\myqueue");

which appears to be different for private queues.

Micorsoft then goes on to explain that this may work for you ...

var queue = new MessageQueue(@".\\myqueue");

Assuming the queue is a local one.

War
  • 8,539
  • 4
  • 46
  • 98
  • Thanks. I am sending the MSMQ messages to a different computer through IP address. – Pearl Aug 25 '17 at 07:30
  • Here you go: https://blogs.msdn.microsoft.com/johnbreakwell/2009/02/26/difference-between-path-name-and-format-name-when-accessing-msmq-queues/ – John Breakwell Aug 26 '17 at 21:03