When I connect WebSphere MQ using C# without installing MQ server and client, I get the exception The type initializer for 'IBM.WMQ.MQQueueManager' threw an exception
. I add the reference of two MQ dlls, amqmdnet.dll
and amqmdxcs.dll
from MQ server, but it doesn't work. How can I connect to MQ without installing MQ server or client? Thank you!
3 Answers
I don't recommend using MQ client libraries without installing them. Installation ensures that all the required binaries are installed and registered with GAC. Adding reference to amqmdxcs is not required. Just a reference to amqmdnet is enough.
So it's better to install MQ client and run your application.

- 14,980
- 2
- 33
- 52
-
Thank you very much!I have comfirmed that it does not work(throw the TypeInitializationException when new QMQueue()) without installing MQ client.But this is a client application,if each computer using the app must install the MQ client(it is not small),I think it's not convenient and inefficient. Maybe there is a better solution. – zhiyuan_ Apr 18 '12 at 15:03
-
IBM doesn't provide a *supported* configuration smaller than the full client install. If this is important to you, please go to https://www.ibm.com/developerworks/rfe/ and submit a Request For Enhancement asking for a small-footprint, supported, client install package. Other people can then vote on that requirement and IBM will see that it is popular (or not) and prioritize accordingly. (I expect this will be quite popular, based on feedback here and other forums but nobody has yet entered the RFE to kick it off.) – T.Rob Apr 18 '12 at 17:55
-
Thank you very much!This a solution but it may be need a long time. – zhiyuan_ Apr 19 '12 at 04:45
Yes you can, you will need the following 2 DLL's: "amqmdnet.dll" and "amqmdxcs.dll"
You can then either:
- Register these 2 DLL's in the Global Assembly Cache (GAC)
- You can just add them as references to your project
Note, however: For option 2 you need to make sure that the registry path "HKEY_LOCAL_MACHINE\SOFTWARE\IBM\WebSphere MQ\Installation" exists.
If it does not exist and the DLL's are not in the GAC you will get the following exceptions:
System.TypeInitializationException: The type initializer for 'IBM.WMQ.MQQueueManager' threw an exception. --> System.TypeInitializationException: The type initializer for 'IBM.WMQ.CommonServices' threw an exception. --> System.NullReferenceException: Object reference not set to an instance of an object.
This is because, when not in the GAC, the 'amqmdxcs.dll' which contains the 'IBM.WMQ.CommonServices' will try to read the sub-keys from the registry path to fill up some variables, but since it does not exist, it will fail.
For me, this approach works without needing any values in the "Installation" key.

- 172
- 11
see also: .net using IBM MQ without full MQ client install
basically grab the 2 dlls from the WMQ bin folder: amqmdnet.dll & amqmdxcs.dll
I found for WMQ 7.5 you need to register the 2 dll's in the GAC for it to work correctly. you need admin persmissions to register them.
the reference the libraries in your project to use the native WMQ objects

- 1
- 1

- 719
- 8
- 7