Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Message count from a remote computer private queue

150 views
Skip to first unread message

Robert Strickland

unread,
Jul 3, 2007, 10:15:55 PM7/3/07
to
Using COM interop to go from .Net (c#) to COM I am using the MSMQ COM class
to get the message count from a local queue. However having tried several
formats I still get the following:

Message: "The format name specified is invalid. "
Source: "MSMQManagement"

when I execute the Init command.

below is my code:

MSMQ.MSMQApplicationClass msmq;
MSMQ.MSMQManagementClass qMgt;
MSMQ.MSMQQueueInfo qInfo;

string id = string.Empty;

object[] queues;
object machineName;
object queueFormatName;
object missingParam;

MSMQ.MSMQApplicationClass msmq;
MSMQ.MSMQManagementClass qMgt;

string id = string.Empty;

object[] queues;
object machineName;
object queueFormatName;
object missingParam;

try
{

missingParam = Type.Missing;
machineName = SystemInformation.ComputerName;

msmq = new MSMQ.MSMQApplicationClass();

queues = msmq.PrivateQueues as object[];

queueFormatName = string.Format("DIRECT=OS:.\nsaprocess",
queueFormatName);

qMgt = new MSMQ.MSMQManagementClass();
qMgt.Init(ref machineName, ref missingParam, ref queueFormatName);

}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

What format is it looking for?

Thanks


Frank Boyne

unread,
Jul 4, 2007, 3:37:25 PM7/4/07
to
"Robert Strickland" <bstri...@comporium.net> wrote in message
news:uJbACFev...@TK2MSFTNGP06.phx.gbl...

> Using COM interop to go from .Net (c#) to COM I am using the MSMQ COM
> class to get the message count from a local queue.

It might be easier to use the System.Management namespace to access the
WMI objects representing the MSMQ performance counters. At least it
would be if you were accessing local counters. Since you are accessing
a remote system's counters things might get a bit messier - I've never
tried remote WMI.

> queueFormatName = string.Format("DIRECT=OS:.\nsaprocess",
> queueFormatName);

There are a couple of odd looking things about this statement. First of
all, the first parameter to string.Format() generally contains one or
more format items (i.e., curly braces containing a number and possibly
other formatting controls like width etc.) into which the text
representation of the corresponding subsequent parameter is inserted.
This call to string.Format doesn't have any format items in the format
string parameter? If insertion/formatting of the other parameters isn;t
required, wouldn;t a simple string assignment statement suffice?

Second, \n in the string literal is going to be interpreted as the
newline character and not as the backslash character followed by the
lower case n character. You either need two backslash characters to
escape the escape sequence or you need to prefix the string literal with
an ampersand as escape sequences in @-quoted literals are not processed.


Robert Strickland

unread,
Jul 16, 2007, 10:42:25 AM7/16/07
to
Thanks for responding.

"Frank Boyne" <frank...@unisys.com> wrote in message
news:OArFBLn...@TK2MSFTNGP06.phx.gbl...

0 new messages