Reputation: 26384
I'm trying to query my local queues on my machine, with the follow code:
var c = new MessageQueueCriteria();
c.MachineName = Environment.MachineName;
var queues = MessageQueue.GetMessageQueueEnumerator(c);
but the code throws an exception on the second line complaining:
A workgroup installation computer does not support the operation.
Stack trace: at System.Messaging.MessageQueue.GetMachineId(String machineName) at System.Messaging.MessageQueueCriteria.set_MachineName(String value)
and the MessageQueueErrorCode enum is set to System.Messaging.MessageQueueErrorCode.UnsupportedOperation.
The strange thing is I am on a domain and not a workgroup! and other application (QueueExplorer) seem to work file. Any ideas how I can get around it?
Update: Seems the error comes from running this piece of code that is in the setter of the property, not sure how to fix it though.
new MessageQueuePermission(MessageQueuePermissionAccess.Browse, "*").Demand();
Upvotes: 1
Views: 763
Reputation: 562
The class MessageQueueCriteria is used to filter PUBLIC message queues when using the GetPublicQueues method. To be able to browse for public queues you must enable the MSMQ Active Directory Services Integration feature. If your computer is joined to a domain is not enough.
If you would like to browse your local PRIVATE queues you should use:
MessageQueue[] queues = MessageQueue.GetPrivateQueuesByMachine(Environment.MachineName);
Upvotes: 2