setmqenv will only affect the session (dos) you are running it in. As for IIS, you cannot mix mq versions. If you want to connect to different versions of MQ, choose the higher one and just know not to use any of the new features when connecting to a lower environment. If you want to use different versions you will need different instances of IIS, each running its own setmqenv
Original Message:
Sent: Thu September 12, 2024 02:25 AM
From: Frank Martin
Subject: The type initializer for 'IBM.WMQ.Nmqi.BindingsNmqiMQ' threw an exception only in ASP.Net web application
If I use setmqenv -s, will it set the environment for all applications including the ones that currently use MQ 7.5?
Because I want existing applications to continue to use MQ 7.5 while I move each application one by one to MQ 9.1.4
------------------------------
Frank Martin
Original Message:
Sent: Thu September 12, 2024 01:33 AM
From: Francois Brandelik
Subject: The type initializer for 'IBM.WMQ.Nmqi.BindingsNmqiMQ' threw an exception only in ASP.Net web application
Because for a desktop application you can initialize the environment with setmqenv whereas IIS runs a a service. Create a startup file for IIS that initializes the environment with
call <path to mq binaries>\setmqenv -s examplecall "c:\program files (x86)\WebSphere MQ\bin\setmqenv" -s..... start IIS here
Hope it helps
------------------------------
Francois Brandelik
Original Message:
Sent: Wed September 11, 2024 01:46 AM
From: Frank Martin
Subject: The type initializer for 'IBM.WMQ.Nmqi.BindingsNmqiMQ' threw an exception only in ASP.Net web application
MQ client 7.5 is already installed on machine and is primary. Then installed MQ client 9.1.4 but didn't make it primary so now this machine has both clients where 7.5 is primary.
Name: WebSphere MQVersion: 7.5.0.6Level: p750-006-160226BuildType: IKAP - (Production)Platform: WebSphere MQ for WindowsMode: 32-bitO/S: Windows Ver 6.2 (7) Server Standard x64 Edition, Build 9200InstName: Installation1InstDesc:Primary: YesInstPath: C:\Program Files (x86)\IBM\WebSphere MQDataPath: C:\Program Files (x86)\IBM\WebSphere MQMaxCmdLevel: 750Name: WebSphere MQVersion: 9.1.4.0InstName: MQ9clientInstDesc: mq9.1InstPath: C:\Program Files\IBM\MQ9ClientPrimary: No
We want to keep 7.5 as primary while we migrate applications to 9.1.4 one by one. For that I created the following environment variable and also added entry in config file of my applications.
Environment Variable
DEVPATH C:\Program Files\IBM\MQ9client\bin
Config Entry
<runtime> <developmentMode developerInstallation="true"/> </runtime>
After that I changed my applications to start using MQ 9.1.4 BUT there is a problem and that is only desktop applications are working fine while all web based application in ASP.Net are throwing this error:
The type initializer for 'IBM.WMQ.Nmqi.UnmanagedNmqiMQ' threw an exception
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Stack Trace
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at IBM.WMQ.Nmqi.NmqiEnvironment.GetInstance(String name) at IBM.WMQ.Nmqi.NmqiEnvironment.GetMQI(Int32 id) at IBM.WMQ.MQQueueManager.Connect(String queueManagerName) at IBM.WMQ.MQQueueManager..ctor(String queueManagerName, Hashtable properties) at WebApplicationNewMW.Middleware.CreateQueueManager() in c:\Documents\Visual Studio 2013\Projects\WebApplication\WebApplication\Middleware.cs:line 43 at WebApplicationNewMW.Default.Page_Load(Object sender, EventArgs e) in c:\Documents\Visual Studio 2013\Projects\WebApplication\WebApplication\Default.aspx.cs:line 17 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)has context menu
Whether I use IISExpress or IIS the issue happens with both. Any idea why desktop based applications work but not web based?
------------------------------
Frank Martin
------------------------------