An unhandled exception of type 'System.Messaging.MessageQueueException' occurred

T

Tony Hamill

Hi,
I am trying to set up a VERY simple project to send message to MSMQ from
..Net using C#. When I run my code it throws an exception

"An unhandled exception of type 'System.Messaging.MessageQueueException'
occurred in system.messaging.dll"

I can only find one other link from Google (
http://www.dotnet247.com/247referen...s/14/73719.aspx )where this has
occured. Can someone help me out here. I find it hard to believe that apart
from myself only one other person has seen this issue.


Source Code:
public void SendMessageTransactional()
{


if (MessageQueue.Exists(@".\Private$\TestQueue"))
{
// Connect to a queue on the local computer.
MessageQueue myQueue = new MessageQueue(@".\Private$\TestQueue");

// Send a message to the queue.
if (myQueue.Transactional == true)
{
myQueue.Send("My Message Data.", "a Label");
return;
}
}
}

I can send messages to the queue from VB6, so the queue itself is fine. The
queue is private, absolutely nothing odd about it. I have created several
queues all the same result from dotnet.

Any help is greatly appreciated, this is very annoying
 
A

Andrew Gnenny

Hi,

I have found that your code checks for message queue transactional mode
(myQueue.Transactional == true) but uses Send method without starting new
transaction. Try the following:

if (myQueue.Transactional == true)
{
using (MessageQueueTransaction trans = new MessageQueueTransaction())
{
trans.Begin();
myQueue.Send("My Message Data.", "a Label", trans);
trans.Commit();
}
return;
}

--
Andrew Gnenny
pulsar2003@/no-spam/email.ru (Please remove /no-spam/ for reply)
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top