I will commence this sequence of posts on MSMQ support on CF version 2.0 by giving some pointers on how to get the Microsoft Message Queuing service up and running on your device. The reason for this is quite obvious, if the Queuing service is not up and running on the device then calling any of the functions to administer or monitor a queue will prove to be an exercise in futility. As a matter of fact if you try to call any of the methods that interact with a message queue when MSMQ is not installed the method will throw an InvalidOperationException with the message “Message Queuing has not been installed on this computer”. On the other hand if the Message Queuing components are present but the service is not running, the call fails with a MessageQueueException with the message “Message Queuing service is not available”.

As can be seen from this article, MSMQ can be built into some custom Windows CE systems (e.g. selecting the MSMQ component in Platform Builder), or rolling up the required MSMQ drivers (you can find them in the SDK) into the cab. Ken Rabold has a good example (complete with sources) on how this can be done for the Pocket PC in his article on devbuzz. Note however that Ken’s example is targeted towards PPC 2000 and PPC 2002. A few things have changed in PPC 2003 (and beyond). The netregd option is no longer needed and the device does not have to be rebooted to get the Messaging Queuing service running. However his example shows how you can install and configure the Messaging Queuing service as part of the application installation process.

I will show how this can be done from managed code (See Part III) by P/Invoking the CreateProcess API, an alternative would be to use the Process class provided in the OpenNETCF libraries. See this article for more information on how to P/Invoke into the CreateProcess API. The msmqadm.exe utility (deployed as part of the MSMQ components) is used to administer the installation process.

You’ll need to run the following to get MSMQ service installed and running

msmqadm.exe register install

msmqadm.exe register

msmqadm.exe enable binary (Enable the proprietary MSMQ binary protocol to send messages to remote queues)

msmqadm.exe enable srmp (Enable the SRMP (SOAP Reliable Messaging Protocol) for sending messages to remote queues over HTTP)

msmqadm.exe start

The following articles would prove to be very useful in providing answers to your device MSMQ installation problems.

MSMQ Installation on Custom Platforms

Programming MSMQ on the PocketPC

Using the MSMQAdm Utility