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!
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.
Yes you can, you will need the following 2 DLL's: "amqmdnet.dll" and "amqmdxcs.dll"
You can then either:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With