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.
- Go to “Start -> Administrative tools -> Computer Management”.
- Expand “Services and Applications”.
- Sselect “Services”.
- Select “Message Queuing”; right click and select “Properties”.
- Select the “Recovery tab”.
- 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:
[sourcecode language=”csharp”]
//Q Creation
if(MessageQueue.Exists(@".Private$MyQueue"))
mq = new System.Messaging.MessageQueue(@".Private$MyQueue");
else
mq = MessageQueue.Create(@".Private$MyQueue");
Queue2 q2 = new Queue2();
q2.Show();
[/sourcecode]