我在使用IronPython訪問MSMQ中的專用隊列時遇到以下異常。 (1)當我使用IronPython控制檯發送和接收消息時,在我的腳本上使用完全相同的命令,它可以工作,(2)私人消息實際上是存在的(即'。\ private $ \ sample) (3)我已經將私人消息的'每個人'用戶的權限設置爲完全控制。腳本中的IronPython:MessageQueue.Receive()異常
這是我使用的代碼段,無論是在IPY控制檯和我的腳本來完成消息的接收:
import clr
clr.AddReference('System.Messaging')
from System.Messaging import *
queue_name = '.\\private$\sample'
queue = None
if MessageQueue.Exists(queue_name) = queue = MessageQueue(queue_name)
else : queue = MessageQueue.Create(queue_name)
print queue.Receive().Body # As mentioned this works in ipy console, but not on script
這裏的例外:
System.Messaging.MessageQueueException (0x80004005): The queue does not exist or you do
not have sufficient permissions to perform the operation.
at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath(String queuePath,
Boolean throwException)
at System.Messaging.MessageQueue.get_FormatName()
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action,
CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction
internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Receive()
at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2
arg2)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0,
T1 arg1)
at Microsoft.Scripting.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
希望有人有一個想法。提前致謝!