IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 2 replies
  • Latest Post - ‏2019-01-09T16:47:04Z by theriaultnicolas
theriaultnicolas
theriaultnicolas
2 Posts

Pinned topic Unable to Put message with character set 37 on .NET Standard

‏2019-01-08T15:52:10Z | characterset netstandard

Hi,

 

I'm using MQ v9.1.1 with amqmdnetstd.dll and it doesn't behave like amqmdnet.dll. My problem occurs with the encoding. Setting CharacterSet = 37 on the MQMessage gives an error when trying to call WriteString because it can't find the encoding for the character set.

 

I'm using the exact same code as when I was using amqmdnet.dll and when tracing into the dlls (decompiled code) it seems like the .net framework library goes into MQCommonServices to convert the string whereas the .net standard library doesn't have access to MQCommonServices and therefore is unable to convert from CCSID 37.

 

What am I missing here? The only CCSIDs the people at the other end will accept are IBM proprietary encodings (37, 273, 277, 278, etc.)

 

I know that all my settings are good. I can connect to the queue and send a message with other encoding (UTF, ASCII, etc.) but they are not readable at the other end. The only readable messages are the one I sent with IBM proprietary encodings when executing my sample app with the .net framework libraries (amqmdnet.dll)

 

here's the code I'm using in my sample application :

            var properties = new Hashtable();
            properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
            properties.Add(MQC.USE_QM_CCSID_PROPERTY, true);
            //properties.Add(MQC.CCSID_PROPERTY,ccsid);
            properties.Add(MQC.HOST_NAME_PROPERTY, host);
            properties.Add(MQC.PORT_PROPERTY, port);
            properties.Add(MQC.CHANNEL_PROPERTY, channelName);

            foreach (var messageString in messageStrings)
            {
                using (var queueManager = new MQQueueManager(queueManagerName, properties))
                {
                    var queue = queueManager.AccessQueue(queueName, MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING);

                    try
                    {
                        var message = new MQMessage()
                        {
                            CharacterSet = 37
                        };
                        
                        message.WriteString(messageString);

                        Console.Write($"Sending: {messageString}");

                        queue.Put(message);

                        Console.WriteLine($"   -Sent!");
                    }
                    catch
                    {
                    }
                }
            }

 

My last resort would be to convert my application to .net framework but I would like to avoid that if possible. All of our other applications are in .net Core as well as our common libraries.

 

Thanks!

  • Ram Subbarao
    Ram Subbarao
    16 Posts
    ACCEPTED ANSWER

    Re: Unable to Put message with character set 37 on .NET Standard

    ‏2019-01-09T08:12:42Z  

    Hi

    You can try by setting "Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);" in your .NET Core application.
    Thanks

  • Ram Subbarao
    Ram Subbarao
    16 Posts

    Re: Unable to Put message with character set 37 on .NET Standard

    ‏2019-01-09T08:12:42Z  

    Hi

    You can try by setting "Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);" in your .NET Core application.
    Thanks

  • theriaultnicolas
    theriaultnicolas
    2 Posts

    Re: Unable to Put message with character set 37 on .NET Standard

    ‏2019-01-09T16:47:04Z  

    Hi

    You can try by setting "Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);" in your .NET Core application.
    Thanks

    Thanks a lot. This is exactly what I needed.

     

    I couldn't find any resource to resolve my issue.

     

    You just saved me and my team a lot of time and trouble.