Possible Duplicate:
Is there a way to check how many messages are in a MSMQ Queue?
How to get message count in MSMQ on another machine, in the same domain (programmatically via C#)?
Note I: My main problem is: I can not even connect to the remote queue.
Note II:
1 - "FormatName:DIRECT=TCP:server2.domain.com\private$\qname" did not work.
2 - "server2.domain.com\private$\qname" did not work.
3 -
using (var q = new MessageQueue(Properties.Settings.Default.MessageQueuePath)) { ... }
did not work.
4 - This:
var q = MessageQueue.GetPrivateQueuesByMachine(Properties.Settings.Default.MessageQueueMachineName).FirstOrDefault();
if (q != null)
using (q)
{
q.Path = Properties.Settings.Default.MessageQueuePath;
q.SetPermissions(
Properties.Settings.Default.MessageQueueUser,
(MessageQueueAccessRights)Properties.Settings.Default.MessageQueuePermission);
q.UseJournalQueue = false; // commented or not
var allMessages = q.GetAllMessages();
if (allMessages != null && allMessages.LongLength > 0) len = allMessages.LongLength;
}
did not work.