maltman
maltman

Reputation: 454

C# Get MSMQ Messages in System Queues

So C# allows me to use GetPrivateQueues and GetPublicQueues but there is nothing to get System Queues. I have written this code

string deadLetterQueuePath = @"formatname:DIRECT=OS:.\system$;DeadLetter";

MessageQueue deadLetterQueue = new MessageQueue(deadLetterQueuePath);

Message[] messages = deadLetterQueue.GetAllMessages();

foreach (Message message in messages)
{
    Console.WriteLine(message.ToString());
    Console.ReadLine();
}

The code fails on the MessageQueue line. Here is the error I get

"The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted."

Could this just be a limitation of running this against my Windows 8 PC? Am I doing something wrong? Could this be a permission issue since the account I am using is not a local admin even when I can pull private and public queues?

Thank you

Upvotes: 1

Views: 719

Answers (2)

John Breakwell
John Breakwell

Reputation: 4687

Something I answered in the old MSMQ newsgroups a while ago might help if it's a permissions problem.

No Manual or Programmatic Access to Dead Letter or Any System Queue

Upvotes: 1

maltman
maltman

Reputation: 454

So the code above is good. Just doesn't work against my Windows 8 box. Works fine on one of my MQ Server 2012 servers.

Upvotes: 0

Related Questions