You may think I am crazy In fact, it seems so unbelievable I don’t quite believe it myself, but I experienced it, and can’t shrug it off. So, on the off chance that someone else might run into this, I am writing down the experience since I couldn’t find a single reference to it when I searched for a solution (which by all means in turn means it’s unlikely that it has happened to all that many people before).

On one environment I was testing MSMQ connectivity. From my brand new BizTalk Server 2009, windows Server 2008 64-bit, environment I wanted to connect to a Windows Server 2003 remote transactional MSMQ queue. Since I wasn’t doing anything remotely service oriented, quite the opposite – it was all about file transfers, I decided to use the “old” MSMQ adapter.

This didn’t work, and failed with the error message:

The adapter "MSMQ" raised an error message. 
Details "The type initializer for '<Module>' threw an exception.".

Ok. So faced with this what do I do? I start local. I created a local private transactional queue, a FILE receive and a MSMQ send – to get a message into the queue. This worked fine.

I then wanted to read the message out from the queue and write it back to disk. This did not work, but failed with the same error message.

I created a second queue, non-transactional, and put a message in there and tried to read it from that, to peel away the transactional aspect. Same non-helpful exception.

I was somewhat at a loss. As I expressed my disgust a colleague asked why I didn’t use the WCF-NetMsmq, and though I had no intention of using it in the final solution that brought on the idea of trying that instead. So I configured a port for that and enabled it.

When I did, I got back the message from the queue. However as I looked in the Event Log I saw error messages from that adapter and looked to see that I had configured it incorrectly – I had continued to put the queue name as xxx\private$\yyy (in the WCF-NetMsmq adapter you don’t use the $). What had happened? I had not gotten the messages with my WCF-NetMsmq port.

As I enabled the WCF-NetMsmq the old MSMQ ports had sprung to life and begun working!

I could now get messages from the local transactional as well as non-transactional queue.

And when I tried the remote queue I now got another, much more helpful, error message:

The adapter "MSMQ" raised an error message. 
Details "This operation is not supported by the remote Message Queuing service.
For example, MQReceiveMessageByLookupId is not supported by MSMQ 1.0/2.0,
or remote receive of the large mesasage cannot be done by the client below v3.5

As it turns out, I can’t make the connection I wanted, as remote transactional queues are not supported by the BizTalk MSMQ adapter in this scenario, on accounts of it not being available in Message queuing 3.0 (which, if you remember, my target system is running since it’s Windows Server 2003). References are here:
%u00b7 http://msdn.microsoft.com/en-us/library/aa562010(BTS.10).aspx
%u00b7 http://blogs.msdn.com/johnbreakwell/archive/2007/12/11/how-do-i-get-transactional-remote-receives.aspx
%u00b7 http://blogs.msdn.com/johnbreakwell/archive/2008/05/21/remote-transactional-reads-only-work-in-msmq-4-0.aspx

But the real point here is not that, but the strange exception I got up front. Repro you ask? Couldn’t get it to happen on any other environment, in fact, on the ones I tried the MSMQ adapter just works. No weird exceptions.