MessageQueueException in ReadHandle

Discussion in 'Microsoft C# .NET' started by Guest, Feb 26, 2004.

  1. Guest

    Guest Guest

    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_CursorHandle(
    at System.Messaging.MessageEnumerator.MoveNext(TimeSpan 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?
     
    Guest, Feb 26, 2004
    #1
    1. Advertisements

  2. Hi Andrew,
    There seems to be some kind of authentication problem between your
    Windows2003 server and the domain controller. The problem occurs in the
    Active Directory access layer "under" MSMQ.

    I would check the following:
    1. Can you see the queues when running Active Directory Users and Computers
    from the Windows 2003 box?
    2. Does your program run as a service / ASP / COM+ component / Cluster
    resource orany other special security context?
    3. When you installed MSMQ, did it ask you for a DS server? (If it did, it
    cannot locate the Active Directory through DNS, and it uses the old MSMQ 1.0
    / 2.0 interface)
    4. Is your DNS configured right? (simple test: ping your DC using its short
    netbioos name, and see if ping says "pinging <netbios name>" or "pinging
    <full DNS name>. The former usually means that DNS is not configured right.

    HTH,
    Yoel
    ---
    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Andrew Hayes" <> wrote in message
    news:...
    > 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)
    > {
    > try
    > {
    > queueItem.Formatter = new BinaryMessageFormatter();
    >
    > queueItem.MessageReadPropertyFilter.SetAll();
    >
    > MessageEnumerator myEnumerator = queueItem.GetMessageEnumerator();
    >
    > while(myEnumerator.MoveNext())
    > {
    > try
    > {
    > 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_CursorHandle()
    > at System.Messaging.MessageEnumerator.MoveNext(TimeSpan timeout)
    > at System.Messaging.MessageEnumerator.MoveNext()
    > at QueueMonitor.EnumerateQueues() in

    c:\projects\queuemonitor\queuemonitor.cs:line 59
    >
    > 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 0
    > 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 -532459699
    > _HResult -2147467259
    > MessageQueueErrorCode -2147023071
    >
    > 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?
     
    Yoel Arnon [MSFT], Feb 26, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony Hamill
    Replies:
    2
    Views:
    832
    Tony Hamill
    Oct 29, 2003
  2. Craig

    EndPeek throwing MessageQueueException

    Craig, Sep 13, 2005, in forum: Microsoft C# .NET
    Replies:
    2
    Views:
    446
    Craig
    Sep 14, 2005
  3. Craig
    Replies:
    0
    Views:
    675
    Craig
    Sep 14, 2005
Loading...

Share This Page