|  | 
 
  
    | RSS Feed - WebSphere MQ Support | RSS Feed - Message Broker Support |  
 
  
	|    |  |  
  
	| Message Queue VB6 to VB.net | « View previous topic :: View next topic » |  
  	| 
		
		
		  | Author | Message |  
		  | Vicky | 
			  
				|  Posted: Sat Feb 24, 2007 7:21 am    Post subject: Message Queue VB6 to VB.net |   |  |  
		  | Newbie
 
 
 Joined: 21 Feb 2007Posts: 5
 Location: India
 
 | 
			  
				| Actually I migrated one app from VB6 to VB.net. 
 This app is using message queue MQIC32.dll
 
 Now when I tried using the same thing from vb.net, I wasn't able to connect to message queue.
 
 I was getting error  "2139" .  i.e .MQRC_CNO_ERROR
 
 So Can I use the migrated vb6 code in vb.net for message queue?
 
 Below are some code snippets  ....
 
 VB6 API:
 Declare Sub MQCONNXAny Lib "MQIC32.DLL" Alias "MQCONNXstd@20" (ByVal QMgrName As String, ConnectOpts As Any, Hconn As Long, CompCode As Long, Reason As Long)
 VB.NET API:
 Declare Sub MQCONNXAny Lib "MQIC32.DLL" Alias "MQCONNXstd@20" (ByVal QMgrName As String, ByRef ConnectOpts As MQCNOCD, ByRef Hconn As Long, ByRef CompCode As Long, ByRef Reason As Long)
 
 And using following API function :
 MQCONNXAny(gsMQMgrName.Value, CNOCD, gHcon, CompCode, Reason)   'Opens the conenction
 ----------------------------------------------------------------------------------------------------------------------------------
 VB6 Structure
 
 Type MQCNOCD
 Dim ConnectOpts As MQCNO 'Options that control the action of MQCONNX'
 Dim ChannelDef As MQCD 'Channel definition for client connection'
 End Type
 
 Type MQCNO
 StrucId          As String * 4 'Structure identifier'
 Version          As Long     'Structure version number'
 Options          As Long     'Options that control the action of MQCONNX'
 ClientConnOffset As Long     'Offset of MQCD structure for client connection'
 ClientConnPtr    As String * 4 'Address of MQCD structure for client connection'
 End Type
 
 Type MQCD
 collection of 64 'Long' & Fixed Length 'Strings'
 End Type
 ---------------------------------------------------------------------------------------------------------------------------------
 
 Upgrade wizard converted DataTypes as follows
 
 <VBFixedString(4),System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray,SizeConst:=4)> Public StrucId() As Char 'Structure identifier'
 Dim Version As Integer 'Structure version number'
 .......................................
 .......................................
 But FixedLength related conversion was generating some Marshaling related error, so we changed the declaration as follows:
 <VBFixedString(4)> Public StrucId As String  'Structure identifier'    [We also tried with Public StrucId As VB6.FixedLengthString]
 ------------------------------------------------------------------------------------------------------------------------------------
 
 Now at the time of execution of API function
 MQCONNXAny(gsMQMgrName.Value, CNOCD, gHcon, CompCode, Reason)   'Opens the conenction
 
 it is returning error code 2139. Please find explanation as follows:
 --------------------------------------------------------------------------------------------------------------------------------------
 
 MQRC_CNO_ERROR (2139)
 
 Explanation: On an  MQCONNX  call, the connect-options structure MQCNO is not valid, for one of the following reasons:
 
 The StrucId field is not MQCNO_STRUC_ID.
 The Version field specifies a value that is not valid or not supported.
 The parameter pointer is not valid. (It is not always possible to detect parameter pointers that are not valid; if not detected, unpredictable results occur.)
 The queue manager cannot copy the changed structure to application storage, even though the call is successful. This can occur, for example, if the parameter pointer points to read-only storage.
 This reason code occurs in the following environments: AIX, HP-UX, z/OS, OS/2, OS/400, Solaris, Windows, plus WebSphere MQ clients connected to these systems.
 
 Completion Code: MQCC_FAILED
 
 Programmer Response: Ensure that input fields in the MQCNO structure are set correctly.
 
 
 Comcode: 2
 Reason Code : 2139
 
 Link: http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaq.doc/csqzaq00221.htm
 
 The link below describes the problem description
 
 http://middleware.its.state.nc.us/middleware/Documentation/en_US/htm/csqzak06/csqzak065m.htm
 (seach for 2139)
 
 Thanks in Advance........
 _________________
 Born For Challenges
 |  |  
		  | Back to top |  |  
		  |  |  
		  | jefflowrey | 
			  
				|  Posted: Sat Feb 24, 2007 9:08 am    Post subject: |   |  |  
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| Do not reference any documentation that is not at IBM.com 
 You don't know if it's trustworthy or not.
 
 I believe you are making too much work for yourself, and causing trouble, by declaring those functions as external LIB functions and trying to use mqic32 directly.
 
 Just migrate the code to the .NET API interface.
 _________________
 I am *not* the model of the modern major general.
 |  |  
		  | Back to top |  |  
		  |  |  
		  | Vicky | 
			  
				|  Posted: Tue Feb 27, 2007 12:49 am    Post subject: |   |  |  
		  | Newbie
 
 
 Joined: 21 Feb 2007Posts: 5
 Location: India
 
 | 
			  
				| 
   
	| jefflowrey wrote: |  
	| Do not reference any documentation that is not at IBM.com 
 You don't know if it's trustworthy or not.
 
 I believe you are making too much work for yourself, and causing trouble, by declaring those functions as external LIB functions and trying to use mqic32 directly.
 
 Just migrate the code to the .NET API interface.
 |  
 Hi,
 
 Thanks for replying.
 
 Can you please tell me in bit detail how to use .NET API and from where can I get it?
 _________________
 Born For Challenges
 |  |  
		  | Back to top |  |  
		  |  |  
		  | Vitor | 
			  
				|  Posted: Tue Feb 27, 2007 12:56 am    Post subject: |   |  |  
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| Vicky wrote: |  
	| Can you please tell me in bit detail how to use .NET API and from where can I get it? |  
 There's a .NET manual in the Info Centre that covers the interface quite extensively. The api comes bundled with the base product AFAIK.
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  |  
		  | Back to top |  |  
		  |  |  
		  | jefflowrey | 
			  
				|  Posted: Tue Feb 27, 2007 4:30 am    Post subject: |   |  |  
		  | Grand Poobah
 
 
 Joined: 16 Oct 2002Posts: 19981
 
 
 | 
			  
				| There are also sample programs that come with the WMQ samples on windows.  C:\Program Files\IBM\WebSphere MQ\Tools\dotnet _________________
 I am *not* the model of the modern major general.
 |  |  
		  | Back to top |  |  
		  |  |  
		  |  |  |  
  
	|    |  | Page 1 of 1 |  
 
 
  
  	| 
		
		  | 
 
 | 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
 
 |  |  |  |