Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using C# to determine Q depth.

Status
Not open for further replies.

sadamahan

Programmer
Jul 21, 2002
2
US
Hi,

Here is a very simple application that uses COM Interop in C# to generate wrapper classes to MQAI.dll and MQAX.dll and make them available to C# programs. I want to know why I get the "System.NullReferenceException" every time at the indicated line.

1. Created a new C# console application.
2. Used COM interop to generate wrapper classes for MQAI.dll and MQAX.dll as detailed in

3. Here is the sample code:

MQSession Session;
MQQueueManager QueueManager;
MQBag adminBag;
MQBag responseBag;
MQBag qAttrsBag;
MQBag errorBag;

//connect
Session = new MQSession();
QueueManager = (MQQueueManager)Session.AccessQueueManager("CRNQ");
if (!QueueManager.IsOpen) return;

//Create an admin bag for the mqExecute call
adminBag = new MQBag();
adminBag.Options = (int)MQ.MQCBO_ADMIN_BAG;

//Create a response bag for the mqExecute call
responseBag = new MQBag();
responseBag.Options = (int)MQ.MQCBO_ADMIN_BAG;

//Put the generic queue name into the admin bag
adminBag.Add("*", MQ.MQCA_Q_NAME);

//Put the local queue type into the admin bag
adminBag.Add(MQ.MQQT_LOCAL, MQ.MQIA_Q_TYPE);

//Add an inquiry for current queue depths
adminBag.AddInquiry((int)MQ.MQIA_CURRENT_Q_DEPTH);

responseBag = (MQBag)adminBag.Execute(QueueManager, (int)MQ.MQCMD_INQUIRE_Q, MQ.MQHB_NONE, MQ.MQHO_NONE , MQ.MQHO_NONE); <-- System.NullReferenceException

I find that I have sent in all the parameters (non null). Is there anything that I am missing here?

Thanks

Sada
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top