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. Node
  3. InvalidCastException: GXDLMSMeter To DB.GXDevice

InvalidCastException: GXDLMSMeter to DB.GXDevice

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 Mikael.Hild , 22 February, 2021
Forums
DLMSDirector

Hi,

I'm testing the DLMS.AMI solution with the GXDLMSDirectory.
Whenever I try to capture and view the Profile Generic data I get a cast exception after refreshing the view:

System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'GXDLMSDirector.GXDLMSDevice'.
at GXDLMSDirector.MainForm.UpdateDescriptionsMenu_Click(Object sender, EventArgs e)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)
System.InvalidCastException: Unable to cast object of type 'Gurux.DLMS.GXDLMSMeter' to type 'Gurux.DLMS.AMI.Messages.DB.GXDevice'.
at Gurux.DLMS.AMI.UI.GXDlmsAmi.GetRowsByRange(GXDLMSMeterBase device, GXDLMSProfileGeneric pg, DateTime start, DateTime end)
at GXDLMSDirector.MainForm.Refresh(Object sender, GXAsyncWork work, Object[] parameters)

This happens after the ObjectController returns the ListObjectResponse.

{SELECT GXObject.`Id`, GXObject.`DeviceId`, GXObject.`TemplateId`, GXObject.`Version`, GXObject.`ObjectType`, GXObject.`Name`, GXObject.`LogicalName`, GXObject.`ShortName`, GXObject.`Generation`, GXObject.`Updated`, GXObject.`Removed`, GXObject.`ExtraInfo`, GXAttribute.`Id`, GXAttribute.`ObjectId`, GXAttribute.`TemplateId`, GXAttribute.`Index`, GXAttribute.`Name`, GXAttribute.`Value`, GXAttribute.`Generation`, GXAttribute.`Updated`, GXAttribute.`Read`, GXAttribute.`TaskId`, GXAttribute.`ExpirationTime`, GXAttribute.`Removed`, GXAttribute.`AccessLevel`, GXAttribute.`Exception`, GXAttribute.`DataType`, GXAttribute.`UIDataType`, GXAttribute.`ExtraInfo` FROM GXObject INNER JOIN GXAttribute ON GXObject.`Id`=GXAttribute.`ObjectId`}

{WHERE ((((GXObject.`Removed` = '0001-01-01 00:00:00') AND (GXObject.`ObjectType` = 7)) AND (UPPER(GXObject.`LogicalName`) LIKE('0.0.98.1.0.126'))) AND (GXAttribute.`Removed` = '0001-01-01 00:00:00') AND (GXObject.`DeviceId` IN (SELECT `DeviceId` FROM GXObject WHERE GXObject.`DeviceId` = 1)))}

Br Mikael

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Security vulnerability report — request for a private contact (GuruxDLMS.c / ANSI C)
  • Topic: Insufficient Memory Error When Reading Class 7 Profile Generic Objects
  • SN ReadResponse returns all-null values when response spans multiple HDLC frames
  • Gurux.Serial.Android 3.0.6 – CH340 (HL-340) USB-Serial Adapter Not Working,
  • Trying to talk to a L&G E360 meter (Using Python Gurux)
More

Who's new

  • Anaglyfos Trading CC
  • cyby
  • Metin Onan
  • ssv007
  • 3nzol3dur
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin