receving and sending message to mqseries server from .net core


i would like to connect to mqseries server having this info

  1. the queue 's name :"myqueue"
  2. connection name:"myconnectionName"
  3. client channel :"mychannel"
  4. server name:"myServerName"

    do i also need to know the queuemanager? or can i use "default" and i am also getting this error message

Unable to load DLL 'mqic32.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)'

        static MQQueueManager queueManager;
        static MQQueueManager qManager;
        static MQQueue queue;
        MQMessage queueMessage;
        MQGetMessageOptions queueGetMessageOptions;
        MQPutMessageOptions queuePutMessageOptions;
        static string QueueName;
        static void Main(string[] args)
         static void Connect()
            var builder = new ConfigurationBuilder()
                .AddJsonFile("AppSettings.json", true, true).Build();

            // Read the Mqseries "connection string" from App.config file.
            var queueManagerName = builder["queueManagerName"];
            var MQChannel = builder["MQChannel"];
            var  queueName = builder["QueueName"];
            string connectionName = builder["ConnectionName"];
            MQAccess(queueName, "Default", connectionName, MQChannel);
            Console.WriteLine("Connected to MQ Queue Manager");
        public static void MQAccess(string queueName, string queueManager, string connection, string channel)
            QueueName = queueName;

            qManager = new MQQueueManager(queueManager, channel, connection);

            queue = qManager.AccessQueue(QueueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
asked on Stack Overflow Feb 6, 2019 by isa • edited Feb 6, 2019 by isa

1 Answer


.NET core support was added in MQ v9.1.1. Again as @JasonE said, you need to use MQ .NET Managed mode only.

Sample code:

Hashtable properties;
MQQueueManager queueManager = null;
try {
    properties = new Hashtable();
    properties.Add(MQC.HOST_NAME_PROPERTY, hostName);
    properties.Add(MQC.PORT_PROPERTY, port);
    properties.Add(MQC.CHANNEL_PROPERTY, channelName);
    properties.Add(MQC.USER_ID_PROPERTY, userName);
    properties.Add(MQC.PASSWORD_PROPERTY, pwd);

    MQQueueManager queueManager = new MQQueueManager(queueManagerName, properties);

}catch(MQException mqex) {
 // Console out exception
answered on Stack Overflow Feb 7, 2019 by Shashi

User contributions licensed under CC BY-SA 3.0