I have a long running process which writes some status messages to msmq. i also have a configuration value which limits the number of message generated by long running process. the code works fine when i use the limit and only write 1/50 of the generated messages to the queue. my code crashes with an access violation exception when the frequency by which I call MSMQEnqueue increases.
the exception is:
First-chance exception at 0x000007fef2096a15 in w3wp.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
does any body know what the limitation could be?
// Retrieves or Creates private queues with the key and sends a message to it
public void MSMQEnqueue(string sKey, string sMessage)
{
MessageQueue queue = GetOrCreateQueue(sKey);
try
{
Message message = new Message();
message.Body = sMessage;
queue.Purge();
queue.Send(message);
}
finally {
queue.Dispose();
}
}
// Retrieves or Creates private queues with a key
public MessageQueue GetOrCreateQueue(string sKey)
{
MessageQueue queue;
// Create and connect to a private Message Queuing queue.
if (!MessageQueue.Exists(string.Format(".\\Private$\\{0}", sKey)))
{
// Create the queue if it does not exist.
queue = MessageQueue.Create(string.Format(".\\Private$\\{0}", sKey));
}
else
{
queue = new MessageQueue(string.Format(".\\Private$\\{0}", sKey));
}
queue.Formatter = new XmlMessageFormatter(new String[] { "System.String,mscorlib" });
queue.MessageReadPropertyFilter.SetAll();
return queue;
}
User contributions licensed under CC BY-SA 3.0