Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Unable To Cast Object of Type 'System.Byte[]' To Type 'System.IConvertible'

Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By Dmitry1 , 23 March, 2021
Forums
Gurux.DLMS

Hi, i'am trying to parse columns information for Profile Generic object (OBIS code 1.0.98.2.0.255). And attempt to parse data from the meter throws the error:

Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.
System.InvalidCastException: Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.
at System.Convert.ToInt32(Object value)
at Gurux.DLMS.GXDLMSClient.UpdateObjectData(GXDLMSObject obj, ObjectType objectType, Object version, Object baseName, Object logicalName, Object accessRights)
at Gurux.DLMS.GXDLMSClient.ParseLNObjects(GXByteBuffer buff, Boolean onlyKnownObjects, Boolean ignoreInactiveObjects)
at Gurux.DLMS.GXDLMSClient.ParseObjects(GXByteBuffer data, Boolean onlyKnownObjects, Boolean ignoreInactiveObjects)
at Gurux.DLMS.GXDLMSClient.ParseObjects(GXByteBuffer data, Boolean onlyKnownObjects)

The request for the captured objects data looking like this:

<HDLC len="18">
<TargetAddress Value="1" />
<SourceAddress Value="20" />
<FrameType Value="32" />
<PDU>
<GetRequest>
<GetRequestNormal>
<InvokeIdAndPriority Value="C1" />
<AttributeDescriptor>
<ClassId Value="0007" />
<InstanceId Value="0100620200FF" />
<AttributeId Value="03" />
</AttributeDescriptor>
</GetRequestNormal>
</GetRequest>
</PDU>
</HDLC>

Reposense from the meter:

<HDLC len="88">
<TargetAddress Value="20" />
<SourceAddress Value="1" />
<FrameType Value="52" />
<NextFrame Value="C401C100010F020412000809060000010000FF0F02120000020412000309060100010800FF0F02120000020412000309060100010801FF0F02120000020412000309060100010802FF0F02120000020412000309060100010803FF0F02120000020412000309060100010880FF0F021200000204120003090601000308" />
</HDLC>

Reply data, which i tried to parse: 010F020412000809060000010000FF0F02120000020412000309060100010800FF0F02120000020412000309060100010801FF0F02120000020412000309060100010802FF0F02120000020412000309060100010803FF0F02120000020412000309060100010880FF0F02120000020412000309060100030801000308

Code C#:

GXDLMSSecureClient _client = new GXDLMSSecureClient();
_client.ParseObjects(new GXByteBuffer(StringToByteArray("010F020412000809060000010000FF0F02120000020412000309060100010800FF0F02120000020412000309060100010801FF0F02120000020412000309060100010802FF0F02120000020412000309060100010803FF0F02120000020412000309060100010880FF0F02120000020412000309060100030801000308")), true);

public static byte[] StringToByteArray(string hex)
{
return Enumerable.Range(0, hex.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
.ToArray();
}

Meter model CE308 S31

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin