title: Receiving message in a transaction
body: <p>I am writing a basic MSMQ producer and consumer and I'm getting tripped up when trying to receive a message as part of a transaction.</p>
  
  <p>The queue is on a Windows Server 2003 machine and it is definitely set to transactional. My producer is able to put messages onto the queue as part of a transaction with no problems. I can read the messages off the queue without problems as well, as long as I don't do it in a transaction. What am I doing wrong?</p>
  
  <p>This is the block of code with which I'm trying to consume the queue:</p>
  
  <pre><code>using (MessageQueue msgQ = new MessageQueue(myQueueName))
  {                   
      try
      {
          using (MessageQueueTransaction msgTx = new MessageQueueTransaction())
          {
              msgTx.Begin();
  
              msg = msgQ.Receive(new TimeSpan(0, 0, 0, 0, 1000), msgTx);
              Console.WriteLine("Message " + msg.LookupId.ToString() + " received");
              msg.Formatter = new XmlMessageFormatter(new string[] { "System.String,mscorlib" });
              if (ParseMessage(msg.Body.ToString()))
              {
                  msgTx.Commit();
                  Console.WriteLine("Message " + msg.LookupId.ToString() + " delivered");
              }
              else
              {
                  msgTx.Abort();
                  Console.WriteLine("Message " + msg.LookupId.ToString() + " not delivered");
              }
          }
      }
      catch (MessageQueueException exc)
      {
          if (exc.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
              Console.WriteLine("No more messages available");
          else
              Console.WriteLine("Unknown error encountered while receiving");
      }
  }
  </code></pre>
  
  <p>So if I remove the <code>using (MessageQueueTransaction ...)</code> encapsulation, everything works fine, except of course that I can't <code>commit</code> or <code>abort</code> the transaction depending on the boolean outcome of <code>ParseMessage(...)</code></p>
  
  <p>When I add the transactional bits though, I get a <code>MessageQueueException</code> as soon as I hit the <code>msgQ.Receive(...)</code> line. The exception message and base is null and the <code>MessageQueueErrorCode</code> is <code>0xc00e008b</code> which, according to <a href="https://msdn.microsoft.com/en-us/library/ms700106%28v=vs.85%29.aspx" rel="nofollow">this MSDN page</a> translates to:</p>
  
  <blockquote>
    <p>MQ_ERROR_OPERATION_NOT_SUPPORTED_BY_REMOTE_COMPUTER (0xC00E008B)</p>
    
    <p>Returned when an attempt is made to receive or peek at a message using
    a lookup identifier from a remote queue residing on a computer running
    MSMQ 1.0 or MSMQ 2.0.</p>
  </blockquote>
  
  <p>Now, to the best of my knowledge, I'm not trying to receive or peek based on a lookup identifier plus, the MSMQ is running on Windows Server 2003 which means it should be MSMQ 3.0 anyway.</p>
  
  <p>What am I getting wrong here?</p>