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. 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

  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200
  • Mon, 06/15/2026 - 08:52
    gurux.dlms.c 9.0.2606.1501

New forum topics

  • Service not known error on gprs communication
  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
More

Who's new

  • ksFhuuipOxKrxk…
  • sherylrk3
  • OLaneHycle
  • LxfgLnoisbruoL…
  • SunbetLith
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin