ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » The type initializer for 'IBM.WMQ.MQQueueManager' threw an

Post new topic  Reply to topic
 The type initializer for 'IBM.WMQ.MQQueueManager' threw an « View previous topic :: View next topic » 
Author Message
kenrickv1
PostPosted: Wed Aug 01, 2012 4:13 am    Post subject: The type initializer for 'IBM.WMQ.MQQueueManager' threw an Reply with quote

Newbie

Joined: 01 Aug 2012
Posts: 5

This is my first time trying to link with IBM MQ. I using some of the example code which comes with the mq client software from ibm and getting the following error:

Quote:
System.TypeInitializationException was unhandled
Message="The type initializer for 'IBM.WMQ.MQQueueManager' threw an exception."
Source="amqmdnet"
TypeName="IBM.WMQ.MQQueueManager"
StackTrace:
at IBM.WMQ.MQQueueManager..ctor(String queueManagerName)
at Debenhams_IBM_windows.Form1.Main(String[] CmdArgs) in C:\Documents and Settings\DKenrick\My Documents\Visual Studio 2005\Projects\Debenhams IBM windows\Debenhams IBM windows\Form1.vb:line 54
at Debenhams_IBM_windows.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\DKenrick\My Documents\Visual Studio 2005\Projects\Debenhams IBM windows\Debenhams IBM windows\Form1.vb:line 9
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Debenhams_IBM_windows.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


I am referencing the dll's amqmdnet and Amqmdxcs. The code I am using is:

Code:
Imports System
Imports IBM.WMQ
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CmdArgs(1) As String
CmdArgs.SetValue("QL.N.RECEIVE", 0)
CmdArgs.SetValue("QM.D.TST", 1)
Main(CmdArgs)
End Sub

Function Main(ByVal CmdArgs() As String) As Integer

Dim mqQMgr As MQQueueManager '* MQQueueManager instance
Dim mqQueue As MQQueue '* MQQueue instance
Dim queueName As String '* Name of queue to use

If (CmdArgs.Length = 0) Then
Return (99)
Else
queueName = CmdArgs.GetValue(0)
End If

'*
'* Try to create an MQQueueManager instance
'*
Try
If (CmdArgs.Length > 2) Then
'* queue name, queue manager name, channel definition all provided

'* Break down the channel definition,
'* which is of the form "channel-name/transport-type/connection-name".
Dim channelDefinition As String = CmdArgs.GetValue(2)
Dim channelName As String
Dim transportType As String
Dim connectionName As String
Dim separator As Char() = "/"
Dim parts As String()

parts = channelDefinition.Split(separator)
If (parts.Length > 0) Then
channelName = parts(0)
End If
If (parts.Length > 1) Then
transportType = parts(1)
End If
If (parts.Length > 2) Then
connectionName = parts(2)
End If
mqQMgr = New MQQueueManager(CmdArgs.GetValue(1), channelName, connectionName)
Else
If (CmdArgs.Length = 2) Then
'* queue name, queue manager name provided
mqQMgr = New MQQueueManager(CmdArgs.GetValue(1))
Else
'* queue name provided - use default queue manager
mqQMgr = New MQQueueManager()
End If
End If
Catch mqe As IBM.WMQ.MQException
'* stop if failed
Return (mqe.Reason)
End Try


'*
'* Try to open the queue
'*
Try
mqQueue = mqQMgr.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING) '* open queue for input but not if MQM stopping
Catch mqe As IBM.WMQ.MQException
'* stop if failed
Return (mqe.Reason)
End Try

'*
'* Get messages from the message queue
'* Loop until there is a failure
'*
Dim isContinue As Boolean = True
Do While (isContinue = True)
Dim mqMsg As MQMessage '* MQMessage instance

Dim mqGetMsgOpts As MQGetMessageOptions '* MQGetMessageOptions instance

mqMsg = New MQMessage()
mqGetMsgOpts = New MQGetMessageOptions()
mqGetMsgOpts.WaitInterval = 15000 '* 15 second limit for waiting
mqGetMsgOpts.Options += MQC.MQGMO_WAIT
Try
mqQueue.Get(mqMsg, mqGetMsgOpts)
If (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) = 0) Then
MsgBox(mqMsg.ReadString(mqMsg.MessageLength))
Else

End If
Catch mqe As IBM.WMQ.MQException
'* report reason, if any
If (mqe.Reason = MQC.MQRC_NO_MSG_AVAILABLE) Then
'* special report for normal end

isContinue = False
Else
'* general report for other reasons


'* treat truncated message as a failure for this sample
If (mqe.Reason = MQC.MQRC_TRUNCATED_MSG_FAILED) Then
isContinue = False
End If
End If
End Try
Loop


Return (0)

End Function
End Class


Any help would be appreciated.


Last edited by kenrickv1 on Wed Aug 01, 2012 4:41 am; edited 1 time in total
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Aug 01, 2012 4:38 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Using "[code]" tags would have been nice.

What did you do to install/copy amqmdnet onto the machine? Do you have a full MQ install?
Back to top
View user's profile Send private message
kenrickv1
PostPosted: Wed Aug 01, 2012 4:47 am    Post subject: Reply with quote

Newbie

Joined: 01 Aug 2012
Posts: 5

I install the WebSphere MQ V7.5 Client for windows on my local pc.
http://www-01.ibm.com/support/docview.wss?uid=swg24032744
This install was how I got amqmdnet onto my machine, visual studio takes a copy. To make sure it is not just my machine I run the program on the server with the mq install on it.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Aug 01, 2012 4:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Okay...

Can you try using the bldvbsamp.bat that comes with the samples, and see if those work?

It might be the configuration of your project that's not doing the link correctly.
Back to top
View user's profile Send private message
kenrickv1
PostPosted: Wed Aug 01, 2012 5:25 am    Post subject: Reply with quote

Newbie

Joined: 01 Aug 2012
Posts: 5

When running the program i got this:

Quote:
C:\D IBM>vmqsget QL.N.RECEIVE
Sample VMQSGET start

Unhandled Exception: System.TypeInitializationException: The type initializer fo
r 'IBM.WMQ.MQQueueManager' threw an exception. ---> System.TypeInitializationExc
eption: The type initializer for 'IBM.WMQ.CommonServices' threw an exception. --
-> System.NullReferenceException: Object reference not set to an instance of an
object.
at IBM.WMQ.CommonServices..cctor()
--- End of inner exception stack trace ---
at IBM.WMQ.CommonServices.TraceEnabled()
at IBM.WMQ.MQBase..ctor()
at IBM.WMQ.Nmqi.NmqiEnvironment..ctor(NmqiPropertyHandler nmqiPropertyHandler
)
at IBM.WMQ.Nmqi.NmqiFactory.GetInstance(NmqiPropertyHandler properties)
at IBM.WMQ.MQQueueManager..cctor()
--- End of inner exception stack trace ---
at IBM.WMQ.MQQueueManager..ctor()
at vmqsget.Main(String[] CmdArgs)
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Aug 01, 2012 5:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Okay.

Was that after you had run bldvbsamp.bat?
Back to top
View user's profile Send private message
kenrickv1
PostPosted: Wed Aug 01, 2012 5:32 am    Post subject: Reply with quote

Newbie

Joined: 01 Aug 2012
Posts: 5

The .exe that I ran was one that the one that bldvbsamp.bat created.
Back to top
View user's profile Send private message
kenrickv1
PostPosted: Thu Aug 02, 2012 2:33 am    Post subject: Reply with quote

Newbie

Joined: 01 Aug 2012
Posts: 5

I found out the problem. It was that the client I installed was a later version then the one installed on the server which meant the dll's I was using where different.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » The type initializer for 'IBM.WMQ.MQQueueManager' threw an
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.