MSMQ on mobile devices complains "Can't read file , incorrect format"

[[Thanks to Brian Dowds for the content]]

 

On a mobile device, you may occasionally see something like "Can't read file \Temp\$localhost$ - {some GUID}.iq, incorrect format." in MSLOGFILE.TXT. If you stop the MSMQ service and delete the queue file mentioned then this fixes the problem.

 

The queue manager will try to initialize a queue before attempting to use it and here are two reasons why the queue manager might post this error:

 

  1. The QM failed to create a queue from the file name during queue initialisation. The queue manager will try to create a queue file in the device file system using a string name stored in the registry.
    Troubleshooting Suggestion - Test whether CreateFile works in general. If it does, then the issue could be contention among threads that are trying to each initialise this particular queue. To test this idea, insert into the message send code some logic that will retry a message send every half-second or so.

     

  2. If the particular queue has the same internal name as the Incoming, Outgoing, MachineJournal or Dead Letter queues (not a likely occurrence).