C# console application

Posted on 2005-04-28
Last Modified: 2008-01-09
i wnat write program for  MQ Series(Series).for that what i must do.means which name space i must import,etc.give me one code.i;ve got one program that program thay are using MQ name space.i am giving the code below.pls find the error.

using System;

namespace dinoch.demo

      public class DotNetMqHello
            private MQAX200.IMQQueueManager200  MyMqManager;
            private MQAX200.IMQSession200       MyMqSession;
            private MQAX200.IMQQueue200         MyMqQueue;
            public DotNetMqHello()
                  MyMqSession = new MQAX200.MQSessionClass();
                  MyMqSession.ExceptionThreshold = 3;

            public static void Main()
                  DotNetMqHello Hello= new DotNetMqHello();

            private void DoIt()

            private void DoConnect()
                  int OpenOptions;
                  String qmName= ""; // use the default local Queue Mgr
                  Object obj = MyMqSession.AccessQueueManager(qmName);

                  if (!(obj is MQAX200.IMQQueueManager200) )
                        Console.WriteLine("Sorry! Could Not get a Queue Manager.");

                        Console.WriteLine("Yes! Got a Queue Manager.");
                        MyMqManager = (MQAX200.IMQQueueManager200) obj;
                        if (MyMqManager != null)
                                    OpenOptions = (int) MQAX200.MQ.MQOO_INPUT_AS_Q_DEF + (int) MQAX200.MQ.MQOO_OUTPUT;
                                    MyMqQueue = (MQAX200.IMQQueue200) MyMqManager.AccessQueue("postcard", OpenOptions,"","","");
                                          Console.WriteLine("Connected to " + + "." + ) ;

            private void DoPut()
                  MQAX200.IMQMessage200 Message;
                  MQAX200.IMQPutMessageOptions200 MessageOptions;

                  Message = (MQAX200.IMQMessage200) MyMqSession.AccessMessage();
                  Message.WriteString(System.DateTime.Now.ToString() + ": This is the test message" );

                  MessageOptions = (MQAX200.IMQPutMessageOptions200) MyMqSession.AccessPutMessageOptions();

                  MyMqQueue.Put(Message, MessageOptions);

                  if(MyMqQueue.CompletionCode == 0)
                        Console.WriteLine("Put Succeeded.");

                  else if(MyMqQueue.CompletionCode == 2)
                        Console.WriteLine("Put Failed (" + MyMqQueue.ReasonName + ")");

            private void DoGet()
                  MQAX200.IMQMessage200 Message;
                  MQAX200.IMQGetMessageOptions200 MessageOptions;

                  Message = (MQAX200.IMQMessage200) MyMqSession.AccessMessage();
                  MessageOptions = (MQAX200.IMQGetMessageOptions200) MyMqSession.AccessGetMessageOptions();

                        // need to specify Missing.Value here because of an issue with the optional 3rd param (length)
                        MyMqQueue.Get(Message,MessageOptions, System.Reflection.Missing.Value);

                        if(MyMqQueue.CompletionCode == 0)
                              Console.WriteLine("Get Succeeded.");

                        else if(MyMqQueue.CompletionCode == 2)
                              Console.WriteLine("Get Failed (" + MyMqQueue.ReasonName + ")");

      } // end class

} // end namespace
Question by:beeravally
    LVL 2

    Expert Comment

    I haven't worked with MQSeries, but in most cases you should receive a few DLLs from along with the software that are .NET assemblies, and you need to add them to your project, only then you will have access to their namespaces.
    What error do you get?
    LVL 10

    Accepted Solution

    You need to add a reference to amqmdnet.dll which you should find in
    C:\Program Files\ibm\WebSphere MQ\bin

    then add the follwoing using statement

    using IBM.WMQAX;


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now