.net '的类型初始值设定项;IBM.WMQ.Nmqi.BindingsNmqiMQ';抛出异常

.net '的类型初始值设定项;IBM.WMQ.Nmqi.BindingsNmqiMQ';抛出异常,.net,ibm-mq,.net,Ibm Mq,尝试以绑定模式连接MQ时(我在本地设置了一台服务器),出现以下异常: System.TypeInitializationException: The type initializer for 'IBM.WMQ.Nmqi.BindingsNmqiMQ' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at IBM.

尝试以绑定模式连接MQ时(我在本地设置了一台服务器),出现以下异常:

 System.TypeInitializationException: The type initializer for 'IBM.WMQ.Nmqi.BindingsNmqiMQ' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at IBM.WMQ.Nmqi.NativeManager.InitializeNativeApis(String mode)
   at IBM.WMQ.Nmqi.BindingsNmqiMQ..cctor()
   --- End of inner exception 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 Project.MQConnector.CreateConnectAndAddQueueManager(QueueManagerConnectionDetails connDetails)
尝试连接到队列管理器时出错,如下所示:

建造商:

Friend queueManagerConnectionProperties As New Hashtable()
queueManagerConnectionProperties.Add(MQC.THREAD_AFFINITY_PROPERTY, True)
If My.Settings.MQConnectAsClient Then
    queueManagerConnectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT)
Else
    queueManagerConnectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_BINDINGS)
End If

queueManagerConnectionProperties.Add(MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_HANDLE_SHARE_BLOCK Or MQC.MQCNO_RECONNECT_Q_MGR) ' have handle-sharing with call blocking
在CreateConnectAndAddQueueManager方法中(其中connDetails只是端口、主机、名称等的存储):

我有以下环境变量:

NMQ_MQ_LIB=mqm.dll
当我使用托管连接(
NMQ\u MQ\u LIB=managed
;并且不设置
MQC.TRANSPORT\u属性
)进行连接时,它可以正常工作

有什么想法吗

--编辑--


看看你最近的评论。您在GAC中有一些不需要的条目。你需要做些清理

1) 打开命令提示符

2) 运行
amqiregisterdotnet.cmd/u
命令以注销MQ.NET程序集

3) 检查Windows GAC哪些MQ.NET程序集。确保没有MQ.NET条目。如果有,请尝试使用
gacutil
命令手动注销

4) 然后运行命令
amqiregisterdotnet.cmd
再次注册程序集


希望这能有所帮助。

您是否安装了完整的MQ客户端或仅使用amqmdnet.dll运行?我已经安装了完整的MQ(具体来说,7.5.0.6-从IIB toolkit附带的7.5.0.1升级而来),如果您能给我一种更具体地检查我安装了什么的方法,这可能会很有帮助Dspmqver-a将列出所有安装的组件。但我认为没有必要设置NMQ_MQ_LIB。应用程序在没有它的情况下应该可以工作。即使没有它,我也会遇到同样的问题。我在运行该命令时(从IIB集成控制台)出现以下错误:“C:\Windows\WinSxS\x86_microsoft.vb80.mfc_1fc8b3b9a1e183eb_8.0.50727.6195_none_cbf5e994470a1a8f\MCF80U.dll不是为在Windows上运行而设计的,或者它包含错误。请尝试使用原始安装介质再次安装程序,或与系统管理员或软件供应商联系以获得支持“对于amqidnet.exe,在messagebox标题中。似乎有五六次您使用了错误的命令。您需要像上面提到的那样运行amqiregisterdotnet.cmd命令。很抱歉,我的意思是,当我运行
amqiregisterdotnet.cmd/u
时,我会收到一个消息框,第一条评论中有错误,消息框的标题是
amqidnet.exe
,您似乎缺少一些Visual Studio可再发行文件。能否尝试从GAC手动删除MQ v7.5.0.3程序集?
NMQ_MQ_LIB=mqm.dll
C:\Program Files\IBM\MQSI\9.0.0.2>dspmqver -a
Name:        WebSphere MQ
Version:     7.5.0.6
Level:       p750-006-160226
BuildType:   IKAP - (Production)
Platform:    WebSphere MQ for Windows
Mode:        32-bit
O/S:         Windows 7 Enterprise x64 Edition, Build 7601: SP1
InstName:    Installation1
InstDesc:
Primary:     No
InstPath:    C:\Program Files (x86)\IBM\WebSphere MQ
DataPath:    C:\Program Files (x86)\IBM\WebSphere MQ
MaxCmdLevel: 750
LicenseType: Production
AMQ8351: WebSphere MQ Java environment has not been configured correctly.
AMQ8351: WebSphere MQ Java environment has not been configured correctly.

Name:        IBM WebSphere MQ custom channel for Windows Communication Foundation
Version:     7.5.0.6
Level:       wn750-006-151116
Build Type:  Production


Name:        IBM Message Service Client for .NET (XMS .NET)
Version:     2.5.0.6
Level:       nn250-006-151116
Build Type:  Production


Name:        IBM Global Security Kit for WebSphere MQ
Version:     8.0.14.53
Build Type:  Production
Mode:        32-bit

Name:        IBM Global Security Kit for WebSphere MQ
Version:     8.0.14.53
Build Type:  Production
Mode:        64-bit