Accessing MessageQueue.FormatName throws an exception on queues returned by GetPrivateQueuesByMachine(remoteMachine) on a workgroup computer - by Jakub Berezanski

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 762194 Comments
Status Resolved Workarounds
Type Bug Repros 1
Opened 9/11/2012 1:42:04 PM
Access Restriction Public


MessageQueue.GetPrivateQueuesByMachineName() returns an array of MessageQueue objects.
When executed on a workgroup computer, passing the name of a remote computer, the returned MessageQueue objects throw an exception when their FormatName property is accessed:

System.Messaging.MessageQueueException (0x80004005): Invalid queue path name.
 at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath(...)
 at System.Messaging.MessageQueue.get_FormatName()

This is a regression, because accessing this property worked in .NET 2.0 and 4.0.

When the FormatName property getter is viewed in ILSpy/Reflector, the difference between .NET 4.5 and earlier is obvious. For the case where queue path is in fact a format name, previous versions did a simple substring operation (to strip the FormatName: prefix). In .NET 4.5, the code is more complicated and ultimately calls the native MQPathNameToFormatName API - which does not support remote paths in workgroup mode and returns an error, causing the exception to be thrown.

Note that the code path which results in a call to MQPathNameToFormatName is taken because GetPrivateQueuesByMachineName sets a private field named queuePath. The MessageQueue constructor does not do this, so for queues constructed from a format name by user code this error does not occur.
Sign in to post a comment.
Posted by Microsoft on 9/11/2012 at 1:52 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(