Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I can tell, this behavior is <em>as intended</em> for <code>MessageQueue.CanWrite</code>. If you delve deep enough into the guts of the MessageQueue class, you'll find it creates some helper objects which influence the value of this property in the following manner:</p> <ol> <li><p>If you pass <code>QueueAccessMode.Send</code> (or <code>SendAndReceive</code>), an internal access mode helper will be created which returns <code>true</code> if <code>(this.accessMode &amp; QueueAccessMode.Send) != (QueueAccessMode)0</code>.</p></li> <li><p>If #1 is <code>true</code>, it then attempts to open the queue to store it into the cache, using the access mode and sharing you have requested. At this point a call to the native method <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms699817%28v=vs.85%29.aspx" rel="nofollow"><code>MQOpenQueue</code></a> is made, which has the following in its remarks (emphasis mine):</p> <blockquote> <p>If the access rights for opening the queue in the mode requested are not allowed for the calling application, the following two things can happen:</p> <ul> <li><strong>If <code>dwAccess</code> is set to <code>MQ_SEND_ACCESS</code>, <code>MQOpenQueue</code> will succeed</strong>, but errors will be returned when the application tries to send a message.</li> <li>If <code>dwAccess</code> is set to <code>MQ_PEEK_ACCESS</code> or <code>MQ_RECEIVE_ACCESS</code>, <code>MQOpenQueue</code> will fail and return <code>MQ_ERROR_ACCESS_DENIED</code> (0xC00E0025). In this case a queue handle is not returned to <code>phQueue</code>. </li> </ul> </blockquote></li> </ol> <p>Therefore, given a <code>QueueAccessMode.Send</code> (or <code>SendAndReceive</code>) with a valid queue name and sharing mode, it is my understanding that <code>CanWrite</code> will return <code>true</code>, even if you truly do not have access to send a message.</p> <p>Basically it appears that you will only receive <code>CanWrite == false</code> if and only if:</p> <ol> <li>You pass a <code>QueueAccessMode</code> which is not <code>Send</code> or <code>SendAndReceive</code>.</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload