Using MSMQ with C#

First add the MSMQ component to your windows installation. Go to Add Remove programs; Add Windows Components; Select Aplication Server; press Details and check Message Queuing

Press Ok; press Finish

Configure the Message and Queing service to restart when errors occur.

  1. Go to “Start -> Administrative tools -> Computer Management”.
  2. Expand “Services and Applications”.
  3. Sselect “Services”.
  4. Select “Message Queuing”; right click and select “Properties”.
  5. Select the “Recovery tab”.
  6. Select “Restart the Service” for first, second and subsequent failures.

Create a new C# Forms project / solution with Visual Studio 2008. Add a reference to the System.Messaging .NET dll.

Add two Forms to the project. Place in the constructor of Form1 the following code:

//Q Creation 

    mq = new System.Messaging.MessageQueue(@".Private$MyQueue"); 
    mq = MessageQueue.Create(@".Private$MyQueue");
Queue2 q2 = new Queue2();

Leave a Reply

Your email address will not be published. Required fields are marked *