我有两个私有消息队列几乎同时出现同样的错误。
var msgLog = _msmqLogging.Receive(TimeSpan.FromSeconds(_timeoutSeconds));
if (msgLog != null) {
var objLogEntry = msgLog.Body as LogEntry;
_dsLog.Create(objLogEntry, _strConnection);
}
我得到的例外是
System.Messaging.MessageQueueException (0x80004005): Operation was cancelled before it could be completed.
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Receive(TimeSpan timeout)
此代码在其他几台计算机上运行,但仅在一台特定计算机上运行。之后,MessageQueue似乎不起作用。从Thread内部调用该方法,并捕获异常。这就是为什么我怀疑这台机器上的MSMQ问题。我将尝试从Event-Log获取更多信息,只是想知道某人是否曾在过去遇到此行为。
在分析Windows事件日志之后,我在收到第一个异常之前立即发现了这些错误消息:
1 user registry handles leaked from \Registry\User\S-1-5-21-1809061258-1204303289-1778214163-1007:
Process 9208 (\Device\HarddiskVolume1\Windows\System32\winlogon.exe) has opened key \REGISTRY\USER\S-1-5-21-1809061258-1204303289-1778214163-1007
1 user registry handles leaked from \Registry\User\S-1-5-21-2206066462-397448001-1194320622-1113:
Process 1056 (\Device\HarddiskVolume1\Windows\System32\svchost.exe) has opened key \REGISTRY\USER\S-1-5-21-2206066462-397448001-1194320622-1113\Printers\DevModePerUser