MSMQ出现间歇性问题,在发送到队列时生成System.IO.IOException
。我没有找到有关此信息的任何信息,因此不确定为什么会发生这种情况(MSDN文档甚至没有列出这个问题)。如上所述它是间歇性的,因此调试很困难,并且不会在开发环境中发生(仅在QA中)
堆栈追踪:
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(System.CodeDom.Compiler.CompilerParameters, System.String[])
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(System.CodeDom.Compiler.CompilerParameters, System.String[])
at System.Xml.Serialization.Compiler.Compile(System.Reflection.Assembly, System.String, System.Xml.Serialization.XmlSerializerCompilerParameters, System.Security.Policy.Evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(System.Xml.Serialization.XmlMapping[], System.Type[], System.String, System.Security.Policy.Evidence, System.Xml.Serialization.XmlSerializerCompilerParameters, System.Reflection.Assembly, System.Collections.Hashtable)
at System.Xml.Serialization.TempAssembly..ctor(System.Xml.Serialization.XmlMapping[], System.Type[], System.String, System.String, System.Security.Policy.Evidence)
at System.Xml.Serialization.XmlSerializer..ctor(System.Type, System.String)
at System.Messaging.XmlMessageFormatter.Write(System.Messaging.Message, System.Object)
at System.Messaging.Message.AdjustToSend()
at System.Messaging.MessageQueue.SendInternal(System.Object, System.Messaging.MessageQueueTransaction, System.Messaging.MessageQueueTransactionType)
at Test.MSMQWrite.WriteMessageInternal(System.String, System.Object, Boolean)
at Test.Program.Main(System.String[])
WriteMessageInternal代码:
private static void WriteMessageInternal(string queueName, object data)
{
using (var queue = new MessageQueue(queueName, false, false, QueueAccessMode.Send))
{
queue.Send(data);
}
}