Hi All
I've got some code that enumerates the public message queues on various remote servers and I've run into a snag..
First, here's a code snippet that is mostly working
MessageQueue[] qList = MessageQueue.GetPublicQueuesByMachine( mName )
foreach(MessageQueue queueItem in qList
tr
queueItem.Formatter = new BinaryMessageFormatter()
queueItem.MessageReadPropertyFilter.SetAll()
MessageEnumerator myEnumerator = queueItem.GetMessageEnumerator()
while(myEnumerator.MoveNext()
tr
mMessageCount++
catch (Exception exp
MessageBox.Show( exp.Message, "Error Getting Message" )
catch (Exception exp
MessageBox.Show( exp.Message, "Error Getting Queue" )
MessageBox.Show( queueItem.Path + ":" + mMessageCount, "Message Count for Queue" )
OK. For most of the servers this works great... Except for 1. It's a newly installed Windows 2003 Server and the myEnumerator.MoveNext() call throws a MessageQueueException with no message text..
Well, I say that but the _message element says "External component has thrown an exception." and _stackTraceString shows
at System.Messaging.MQCacheableInfo.get_ReadHandle(
at System.Messaging.MessageEnumerator.get_CursorHandl e(
at System.Messaging.MessageEnumerator.MoveNext(TimeSp an timeout
at System.Messaging.MessageEnumerator.MoveNext(
at QueueMonitor.EnumerateQueues() in c:\projects\queuemonitor\queuemonitor.cs:line 5
So, I put in a breakpoint on the queueItem.Formatter line and hit Shift+F9 to QuickWatch queueItem... That's when I noticed
ReadHandle <error: an exception of type: {System.Messaging.MessageQueueException} occurred
I step through to after the myEnumerator construction and take a look at that
Handle
Current <error: an exception of type: {System.InvalidOperationException} occurred
CursorHandle <error: an exception of type: {System.Messaging.MessageQueueException} occurred
Seems I can't get the Handle for the Message Queue, which in turn means I can't get a Handle for the Enumerator... So I checked the security on the remote public queue I was enumerating and ( like everyone else on these NG's seems to do ) it was set to Everyone - Full Control... My machine and the remote machine both belong to the same Active Directory domain, and DNS is correctly setup for that to work... I believe..
Looking at the Exception instance I also see
_COMPlusExceptionCode -53245969
_HResult -214746725
MessageQueueErrorCode -214702307
Searching for 0x80070721 (-2147023071) seems to indicate it's a DCOM Automation error to do with security packages, so maybe there is something extra I need to do in 2K3 to allow me to enumerate the messages in the public queues..
Anyone have any thoughts, comments, ideas, suggestions or, preferably, solutions?