2016-06-10 538 views
0

當試圖連接到MQ的綁定模式(我有一個服務器架設在本地),我得到以下異常:爲「IBM.WMQ.Nmqi.BindingsNmqiMQ」的類型初始值引發了異常

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僅僅是一個存儲用於p ORT,主機名等):

Dim specificQMConnProperties As Hashtable = CType(queueManagerConnectionProperties.Clone(), Hashtable) 
specificQMConnProperties.Add(MQC.CHANNEL_PROPERTY, connDetails.Channel) 
specificQMConnProperties.Add(MQC.CONNECTION_NAME_PROPERTY, connectionName) 
Dim qmgr As MQQueueManager = Nothing 

Try 
    qmgr = New MQQueueManager(connDetails.Name, specificQMConnProperties) 
Catch ex As MQException 
    ' error handling 
End Try 

我有以下環境變量:

NMQ_MQ_LIB=mqm.dll 

當我連接使用受管理的連接(NMQ_MQ_LIB=managed;並且不要設置MQC.TRANSPORT_PROPERTY),它工作正常。

有什麼想法?

- 編輯 -

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 
+0

您是否安裝了完整的MQ客戶端或者只是運行了amqmdnet.dll? – Shashi

+0

我已經安裝了完整的MQ(具體來說,7.5.0.6 - 從IIB工具包帶來的7.5.0.1升級而來) – simonalexander2005

+0

如果您可以給我一種更具體地檢查我已安裝的內容的方法,那可能會有所幫助 – simonalexander2005

回答

1

看你的最新評論。您在GAC中有一些不需要的條目。你需要做一些清理。

1)打開命令提示符。

2)運行amqiregisterdotnet.cmd /u命令來取消註冊MQ .NET程序集。

3)檢查Windows GAC什麼MQ .NET程序集。確保沒有MQ .NET條目。如果有的話,嘗試使用gacutil命令手動取消註冊。

4)然後運行命令amqiregisterdotnet.cmd再次註冊組件。

希望這會有所幫助。

+0

運行該命令(從IIB集成控制檯)時出現以下錯誤:「C:\ Windows \ WinSxS \ x86_microsoft.vb80.mfc_1fc8b3b9a1e183eb_8.0.50727.6195_none_cbf5e994470a1a8f \ MCF80U.dll不是爲在Windows上運行而設計的或者它包含錯誤,請嘗試使用原始安裝介質重新安裝該程序,或與系統管理員或軟件供應商聯繫以獲取支持「 – simonalexander2005

+0

for amqidnet.exe」的消息框標題。它出現五六次 – simonalexander2005

+0

您正在使用錯誤的命令。您需要運行amqiregisterdotnet.cmd命令,如上所述。 – Shashi

相關問題