The .NET MQ Adpater is built on v4.7.2.
Original Message:
Sent: Fri November 24, 2023 08:18 AM
From: Francois Brandelik
Subject: Access Violation Error when using CCDT (channel definition TAB) file
Your .NET framework version looks quite old: Framework Version: v4.0.30319
Can you please check the reference version required with MQ 9.0.2.6. IIRC the minimum version for the framework would be 4.5.
------------------------------
Francois Brandelik
Original Message:
Sent: Fri November 24, 2023 03:44 AM
From: Balaji Patil
Subject: Access Violation Error when using CCDT (channel definition TAB) file
Sorry for not being clear with my question.
We have 2 types of adapters Inbound and Outbound:
1. For Inbound we do pass all the required details as below. We are not using the CCTD file for Inbound:
2. For Outbound we are passing only QueueManager and Queue, rest details will be captured from the CCTD file:

We are not parsing the CCTD file anywhere in the code.

For Outbound when using CCTD file:
1. QueueManagerName: Appended with an asterisk (*) symbol Infront of the Queue Manager
2. QueueName: Queue name for sending outbound messages
3. HostName: Will be blank
4. ChannelName: Will be blank
5. Port: Will be 0
The Details of HostName, ChannelName and Port will be fetched from the CCTD file.
Hope that's clear.
------------------------------
Balaji Patil
Original Message:
Sent: Thu November 23, 2023 04:04 PM
From: Roger Lacroix
Subject: Access Violation Error when using CCDT (channel definition TAB) file
So, you are the person who posted the same question on StackOverflow?
Looking at this question and your "MQClose and Disconnect" question, there is something very suspicious going on. You claim to be using a CCDT file and setting the MQCHLLIB and MQCHLTAB environment variables (on StackOverflow) but I see the following in your code samples:
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);connectionProperties.Add(MQC.HOST_NAME_PROPERTY, MQHostName);connectionProperties.Add(MQC.PORT_PROPERTY, MQPort);connectionProperties.Add(MQC.CHANNEL_PROPERTY, MQChannel);//In case of network issues - reconnect to same queue manager if (!string.IsNullOrEmpty(MQHostName)) { connectionProperties.Add(MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT_Q_MGR); connectionProperties.Add(MQC.CONNECTION_NAME_PROPERTY, String.Format("{0}({1})", MQHostName, MQPort));
If you are using a CCDT file then why are you setting hostname, port & channel name in your code? It looks to me that you have some code that is parsing the CCDT and then using those values in your code. That doesn't make any sense.
If you truly have a CCDT file set via MQCHLLIB and MQCHLTAB environment variables, then this is what your code should look like:
var connectionProperties = new Hashtable();
connectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
connectionProperties.Add(MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT_Q_MGR);
//Start Creating Inbound connection for reading the messages.
if ( (!string.IsNullOrEmpty(MQManagerName)) && (!string.IsNullOrEmpty(MQQueueNameIn)) )
{
queueManagerIn = new MQQueueManager(MQManagerName, connectionProperties);
queueIn = queueManagerIn.AccessQueue(MQQueueNameIn, MQC.MQOO_BROWSE + MQC.MQOO_INPUT_SHARED + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);
}
IBM does not publicly post the layout of the CCDT file. Your code should not be parsing the CCDT file because you will be guessing at the format.
Plus, you also said:
> This is maybe due to multiple threads trying to access at the same time?
So, I'm thinking that you have many threads opening and parsing the CCDT file. I have so many questions about the design of your program. Because if it is designed the way you are describing it, it is very bad idea. Problem areas:
- Not letting the MQ client library handle the connection via a CCDT file
- If parsing, then why wasn't it done once and only once in the master process then the connection info passed to each thread.
- I don't see try/catch logic around each MQ API call, hence, memory leaks can happen.
I would strongly suggest that you have a code walk-thru of this program with a few people that have MQ programming experience.
later
Roger
------------------------------
Roger Lacroix
CTO
Capitalware Inc.
London ON Canada
https://capitalware.com
Original Message:
Sent: Tue November 21, 2023 02:09 AM
From: Balaji Patil
Subject: Access Violation Error when using CCDT (channel definition TAB) file
Hello MQ Experts,
We are using the channel definition file to get the hostname and channel based on queue manager name.
But sometimes we are seeing the below error, is there any solution for this.
This is maybe due to multiple threads trying to access at the same time?
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at System.Runtime.InteropServices.Marshal.PtrToStructureHelper(IntPtr, System.Object, Boolean)
Details:
- What kind of CCDT file is it? Binary or JSON? -Binary
- Is your .NET application running in managed or non-managed mode? -Managed
- What version of the MQ Client software are you using? -9.2.0.6
- What release of MQ created the CCDT file? -8.x
- Show us the C# code that creates the parameters and newing of the MQQueueManager class enter code here
var connectionProperties = new Hashtable(); connectionProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);if (!string.IsNullOrEmpty(MQHostName)) { connectionProperties.Add(MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT_Q_MGR); connectionProperties.Add(MQC.CONNECTION_NAME_PROPERTY, String.Format("{0}({1})", MQHostName, MQPort));}if (MQQueueNameIn != null && MQQueueNameIn.Length > 0){ queueManagerIn = new MQQueueManager(MQManagerName, connectionProperties); queueIn = queueManagerIn.AccessQueue(MQQueueNameIn, MQC.MQOO_BROWSE + MQC.MQOO_INPUT_SHARED + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE);}
------------------------------
Balaji Patil
------------------------------