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
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