| Author | 
		  Message
		 | 
		
		  | fraeliz | 
		  
		    
			  
				 Posted: Wed Aug 24, 2011 8:36 am    Post subject: MQQueueManager instance gets protected memory error | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 24 Aug 2011 Posts: 2
  
  | 
		  
		    
			  
				I have been working on this issue for quite a few days and need help.
 
I am trying to connect to queue manager using vb.net  (VS 2008 framework 3.5).  When creating instance/connecting to queue manager I am getting the error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt. " 
 
 
My string is coming from a dataset.  If i 'hardcode' the mq manager name to a string I don't get the error.  If I assign the string from a dataset or datareader item.   I get the error.  
 
 
Note the error is not thrown in the MQ exception block, but the normal .net exception
 
Pertinent code is as follows:
 
     
   
	| Code: | 
   
  
	   Dim mqQMgr As MQQueueManager            '* MQQueueManager instance
 
        Dim mqQueue As MQQueue                  '* MQQueue instance
 
        Dim mqMsg As MQMessage                  '* MQMessage instance
 
        Dim mqPutMsgOpts As MQPutMessageOptions '* MQPutMessageOptions instance
 
        Dim boolQueueInfoExist As Boolean = True
 
        Dim strExceptionMessage As String = ""
 
        Dim strQueueName As String = ""
 
        Dim intExpirationTime As Integer = 0
 
        Dim strQueueMgr As String = ""
 
        Dim strCommand As String = ""
 
        Dim dsRequest As New DataSet
 
 
    
 
        Try
 
           
 
            strCommand = "SELECT mbeq.MSG_QUEUE_NAME, mbeq.MSG_QUEUE_MGR,mbeq.EXPIRATION_TIME "
 
            strCommand = String.Concat(strCommand, " FROM " & STR_CONFIG_DB & ".dbo.trgt_mbe_queue_info mbeq")
 
            strCommand = String.Concat(strCommand, " WHERE mbeq.PZAP_APP_ID = " + "'" + pstrAppId + "'")
 
            strCommand = String.Concat(strCommand, " AND mbeq.PZAP_APP_ID_XCOM = " + "'" + pstrXcomId + "'")
 
 
            dsRequest = m_objDbConn.ExecuteDataSet(strCommand)
 
 
            strQueueMgr = CType(dsRequest.Tables(0).Rows(0).Item(1), String)
 
            strQueueName = CType(dsRequest.Tables(0).Rows(0).Item(0), String)
 
            intExpirationTime = CInt(dsRequest.Tables(0).Rows(0).Item(2))
 
            
 
            If (strQueueMgr.Length > 0) Then
 
                '* queue manager name provided
 
  
 
                mqQMgr = New MQQueueManager(strQueueMgr)
 
 
 
            Else
 
                '* queue manage name not provided - use default queue manager
 
                mqQMgr = New MQQueueManager()
 
            End If
 
 
 
        Catch mqe As IBM.WMQ.MQException
 
            If m_strAppId <> "EADJ" And m_strAppId <> "EADM" Then
 
                MsgBox("Unable to instantiate MQQueueManager instance named: " & strQueueMgr)
 
                MsgBox("Mqe.Message = " & mqe.Message)
 
            End If
 
 
            Throw mqe
 
 
        Catch objException As Exception
 
 
            dsRequest = Nothing
 
        
 
            Throw objException
 
 
        End Try | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | muthum_2000 | 
		  
		    
			  
				 Posted: Tue Sep 27, 2011 8:55 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Voyager
 
 Joined: 10 Jul 2006 Posts: 85
  
  | 
		  
		    
			  
				Try to bring down MQ and clear all the semaphores related to mqm.
 
 
Then try bringing up the MQ manager and check if your app works. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | exerk | 
		  
		    
			  
				 Posted: Tue Sep 27, 2011 9:11 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 02 Nov 2006 Posts: 6339
  
  | 
		  
		    
			  
				Also search this site. I think something like this came up in the recent past. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Tue Sep 27, 2011 9:12 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				| I suspect your code is causing a pointer to the field in the result set to be passed in to the MQQueueManager constructor, rather than a copy of the string data in the field in the result set. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fraeliz | 
		  
		    
			  
				 Posted: Tue Sep 27, 2011 9:48 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 24 Aug 2011 Posts: 2
  
  | 
		  
		    
			  
				I don't see a website in the post that refers to one.
 
 
For other post on 'pointer', so in this case it does become a .net odbc result set type question.
 
 
How does one convert from a 'pointer' type of reference to an actual copy of the string.  It's not being passed as a parameter so not a matter of byref or byval type thing. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | ankurlodhi | 
		  
		    
			  
				 Posted: Tue Sep 27, 2011 10:31 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Master
 
 Joined: 19 Oct 2010 Posts: 266
  
  | 
		  
		    
			  
				the looks ok. it can be possible that variable you are trying to write is private, or something like that give a try with checking the excess permissions a have scene these kind of errors when i was working on .net. 
 
 
 
but its only a guess work from me. u might be missiong something. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | gbaddeley | 
		  
		    
			  
				 Posted: Tue Sep 27, 2011 5:02 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| My string is coming from a dataset. If i 'hardcode' the mq manager name to a string I don't get the error. If I assign the string from a dataset or datareader item. I get the error.  | 
   
 
 
 
MQCONN / New MQQueueManager in VB & VB.net seems to be a bit quirky about where the queue manager name comes from. I suggest using a global string variable. _________________ Glenn | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |