我正在尝试获取MSMQ中的消息数。我发现在互联网上的代码(多次):无法获取MSMQ Com来查找我的队列
// setup the queue management COM stuff
MSMQManagement _queueManager = new MSMQManagement();
object machine = "MyLaptopComputer";
object path = @"DIRECT=OS:MyLaptopComputer\PRIVATE$\MyQueue";
_queueManager.Init(ref machine, ref path);
Console.WriteLine(_queueManager.MessageCount);
Marshal.ReleaseComObject(_queueManager);
每次我去_queueManager.Init
它失败,此错误:
The queue path name specified is invalid.
我已经检查(和双重检查)我的队列名称看看这是否是错误的。我尝试了不同的队列,不同的机器,运行远程,运行本地......没有任何工作。
我也尝试过上面的代码的变体。例如,我曾尝试:
_queueManager.Init("MyLaptopComputer", @"DIRECT=OS:MyLaptopComputer\PRIVATE$\MyQueue");
的队列与NServiceBus和功能就好用,当我用NServiceBus访问它们。
有没有人有关于如何让这个工作的想法?
您是否尝试过使用“localhost”或“。”在你的道路上,而不是你明确的电脑名称? – 2012-03-08 17:50:08
@SeanH我曾尝试“。”。但是,我应该在放弃之前尝试一下。看到我的答案,看看我的工作变化。 – Vaccano 2012-03-08 18:13:46
为什么你在使用COM类时有一个完美的Api。网络框架,因为你使用的是C#? – 2012-03-08 22:53:05