Author |
Message
|
desmetk |
Posted: Mon Apr 23, 2007 5:11 am Post subject: .NET error : Attempted to read or write protected memory ... |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 4
|
Hello,
Im not sure if this is the correct place to post this issue but anyway ...
Some background :
We're implementing an application that is using MQ client to connect to a remote queue manager. We where able to get it to work but after sending some messages to the remote machine we get the next message and the application is hanging:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
We are using VB.NET and this is the code fragment where we could reproduce the error with ! Does anyone has an idea what is going on?
Thanks in advance,
Public Sub SendMessage()
Dim QMgr As MQQueueManager
Dim OutputQueue As MQQueue
Dim mqMsg As MQMessage
Dim mqPutOptions As MQPutMessageOptions
MQEnvironment.Hostname = _host
MQEnvironment.Channel = _channel
QMgr = New MQQueueManager(_broker)
Dim OutOptions As Integer
OutOptions = MQC.MQOO_OUTPUT Or MQC.MQOO_FAIL_IF_QUIESCING
OutputQueue = QMgr.AccessQueue(_queue, OutOptions)
mqMsg = New MQMessage
mqMsg.Persistence = 1
mqMsg.MessageType = MQC.MQMT_DATAGRAM
mqMsg.Format = MQC.MQFMT_STRING
mqMsg.WriteChars(_message)
mqPutOptions = New MQPutMessageOptions
' Send the message
OutputQueue.Put(mqMsg, mqPutOptions)
QMgr.Disconnect()
QMgr.Close()
OutputQueue.Close()
QMgr = Nothing
OutputQueue = Nothing
mqMsg = Nothing
mqPutOptions = Nothing
End Sub |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2007 5:32 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
What version of MQ are you using? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
yortch |
Posted: Mon Apr 23, 2007 5:52 am Post subject: |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
Not sure if this is what's causing your problem, but you should close the queue before disconnecting from the queue manager. |
|
Back to top |
|
 |
desmetk |
Posted: Mon Apr 23, 2007 6:25 am Post subject: Version MQ |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 4
|
The version we are using is 5.3 |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2007 6:32 am Post subject: Re: Version MQ |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
desmetk wrote: |
The version we are using is 5.3 |
Patched to which level??
And yortch is right, you should close the queue before you disconnect from queue manager. After you disconnect, close is impossible. It should fail gracefully, but under earlier versions this may not be the case. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
desmetk |
Posted: Mon Apr 23, 2007 6:37 am Post subject: |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 4
|
Currently no patches applied, we where looking onto the site of IBM and found out that there is a patch 6 where a problem is fixed that might be related to ours?
It is possible that there where patches linked to our installation, can you tell me where to look for the type of patches applied?
btw, I have closed before disconnecting and have the same problem.
Thanks,
Kurt |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2007 6:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
If you're on v5.3 with no patches applied I'm not surprised you're having problems!!
Never mind 6 which is as old as the hills, go to the latest level (CSD12) and try it again.
Patches have no type, they are supplied as CSDs. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2007 6:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
desmetk wrote: |
btw, I have closed before disconnecting and have the same problem.
|
Fair point, but it would still never work the other way round. You need an active connection to close the queue over.
I'd give up on further code changes until you've got to a stable level of MQ. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
yortch |
Posted: Mon Apr 23, 2007 7:24 am Post subject: |
|
|
Apprentice
Joined: 30 Aug 2004 Posts: 34
|
Quote: |
We where able to get it to work but after sending some messages to the remote machine we get the next message |
Are you still able to get it to work?
Which line of code is this exception thrown?
Do you see any errors logged on the windows event log on the server where MQ is running?
Are you using .NET 2.0/VS2005 by any chance? I've found several posts where this occurs on .NET 2.0 apps (not using MQ) |
|
Back to top |
|
 |
kevinf2349 |
Posted: Mon Apr 23, 2007 5:05 pm Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
I thought .Net support only came along with CSD7? Or was that only when it started working well enough to use?  |
|
Back to top |
|
 |
Vitor |
Posted: Mon Apr 23, 2007 11:49 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
kevinf2349 wrote: |
I thought .Net support only came along with CSD7? Or was that only when it started working well enough to use?  |
Either way, I wouldn't use anything much below CSD 10 with any level of confidence.....
For anything  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
ashu |
Posted: Tue Apr 24, 2007 3:50 am Post subject: |
|
|
 Centurion
Joined: 11 Nov 2006 Posts: 132
|
Code: |
QMgr.Disconnect()
QMgr.Close()
OutputQueue.Close() |
??????  |
|
Back to top |
|
 |
desmetk |
Posted: Tue Apr 24, 2007 4:00 am Post subject: |
|
|
Newbie
Joined: 23 Apr 2007 Posts: 4
|
Hello,
Thanks all for your kind input, we have installed CDS13 and now the problems are solved. I would like to thank all of you agian to point us into the right direction.
Kurt |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 24, 2007 5:29 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
ashu wrote: |
Code: |
QMgr.Disconnect()
QMgr.Close()
OutputQueue.Close() |
??????  |
As yorch correctly drew our attention to further up the post.... _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|