|
-
Oct 27th, 2003, 04:18 PM
#1
Thread Starter
Addicted Member
An unhandled exception of type 'System.Messaging.MessageQueueException' occurred
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/247referenc.../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
-
Oct 27th, 2003, 09:08 PM
#2
Hyperactive Member
Not having much experience using .NET and MQ I decided to take a stab at this one. I couldn't get it to error out. If it makes a difference, I'm on a Win2K Advanced Server(SP4) that's not a domain controller and is part of a workgroup, so I can only have private queues. This is the code I used to read and write to the queue:
PHP Code:
using System;
using System.Messaging;
namespace MessageQueueTest
{
public class MainApp
{
public static void Main(string[] args)
{
//Connect to a queue
MessageQueue sender = new MessageQueue(".\\Private$\\temp");
//Create a new message
Message msgSent = new Message("Hello World!");
//Set the type of formatting to use for the message
msgSent.Formatter = new BinaryMessageFormatter();
//Send it to the queue
sender.Send(msgSent);
//Create another connection to the same queue
MessageQueue receiver = new MessageQueue(".\\Private$\\temp");
//Try to receive the message
Message msgReceived = receiver.Receive();
//Set the type of formatting to use for reading the message
msgReceived.Formatter = new BinaryMessageFormatter();
//What was in the message?
Console.WriteLine(msgReceived.Body.ToString());
Console.ReadLine();
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|