Sdílet prostřednictvím


"Invalid Parameter" when receiving from a remote queue

I'm backing up a colleague who is out on vacation this week and got an interesting issue from one of his customers.  They'd implemented a simple Windows Service in C# (v1.1) to read messages from a remote MSMQ queue. 

The issue they ran into is when the server the remote queue went down, they'd get "MSMQ Unavailble" errors, which is expected.  Once the queue comes back online, they were getting "An invalid parameter passed to a function"  After a bit of digging this looks to be a bug in the framework related to some caching of the connection to the queue.  After the queue comes back up, the cached connection is no longer valid.  Fortunately the workarounds (2) are fairly simple:

Disable the connection caching via:
System.Messaging.MessageQueue.EnableConnectionCache = False;

Or

Clear the cache after catching the error and retry receiving on the queue:
System.Messaging.MessageQueue.ClearConnectionCache()

From what I could gather from reading the notes in the bug, it has been address, but I'm speculating since the workaround is fairly simple, no hotifx has been made yet. I'd expect it in a future release, I just have no idea which one.