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. Cast GXDLMSMeter To GXDLMSDevice

Cast GXDLMSMeter to GXDLMSDevice

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 , 13 October, 2022
Forums
DLMSDirector

Hi,

For the last year or so, using DLMSDirector viewing devices in AMI causes an 'System Null Reference Exception' when trying to view a clock object, profile generic etc.

In the SelectItem method (line 453 MainForm.cs) it calls the GetDevice method (line 693 MainForm.cs) which returns a null device.

Inside the GetDevice(GXDLMSObject item) method (line 116 MainForm.cs) it gets the GXDLMSDevice from the GXDLMSObject.Parent.Tag. Casting this to a GXDLMSDevice returns null.

I don't know if there could be some property we're using which has been populated by un unexpected data type or why it doesn't work. Attached is a sample device.

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Gurux.DLMS.UI.GXDLMSClockView.OnAccessRightsChange(GXDLMSViewArguments arg) in C:\vsts-agent\_work\5\s\development\GXDLMSClockView.cs:line 118
at Gurux.DLMS.UI.GXDlmsUi.UpdateAccessRights(IGXDLMSView view, GXDLMSClient client, GXDLMSObject target, Boolean connected) in C:\vsts-agent\_work\5\s\development\GXDlmsUi.cs:line 521
at Gurux.DLMS.UI.GXDlmsUi.ObjectChanged(IGXDLMSView view, GXDLMSClient client, GXDLMSObject target, Boolean connected) in C:\vsts-agent\_work\5\s\development\GXDlmsUi.cs:line 538
at GXDLMSDirector.MainForm.SelectItem(Object obj) in C:\Users\mihi\Desktop\Github\GXDLMSDirector\Development\MainForm.cs:line 725

Device JSON: (sensitive information has been replaced with "x").

{
"id": 5,
"dc": 0,
"templateId": 4,
"type": null,
"clientSystemTitle": "",
"deviceSystemTitle": "",
"blockCipherKey": "",
"authenticationKey": "",
"generation": "0001-01-01T00:00:00",
"updated": "2022-10-13T10:44:43+02:00",
"detected": "0001-01-01T00:00:00",
"removed": "0001-01-01T00:00:00",
"objects": null,
"dynamic": false,
"extraInfo": 0,
"traceLevel": 0,
"waitTime": 5,
"resendCount": 3,
"maximumBaudRate": 0,
"authentication": 1,
"authenticationName": null,
"standard": 0,
"password": "x",
"hexPassword": null,
"security": 0,
"securitySuite": 0,
"keyAgreementScheme": 0,
"systemTitle": "",
"serverSystemTitle": "",
"dedicatedKey": "",
"preEstablished": false,
"invocationCounter": 0,
"frameCounter": null,
"challenge": "",
"clientSigningKey": null,
"clientAgreementKey": null,
"serverSigningKey": null,
"serverAgreementKey": null,
"physicalAddress": 59047450,
"logicalAddress": 1,
"utcTimeZone": false,
"dateTimeSkips": 0,
"clientAddress": 32,
"startProtocol": 1,
"useRemoteSerial": false,
"interfaceType": 0,
"useFrameSize": false,
"maxInfoTX": 128,
"maxInfoRX": 128,
"windowSizeTX": 1,
"windowSizeRX": 1,
"macSourceAddress": 3072,
"macDestinationAddress": 0,
"pduSize": 65535,
"userId": -1,
"networkId": 0,
"physicalDeviceAddress": null,
"inactivityTimeout": 110,
"serviceClass": 1,
"priority": 1,
"serverAddressSize": 0,
"name": "59047450",
"verbose": true,
"conformance": 311352,
"manufacturer": "59047450",
"hdlcAddressing": 1,
"useProtectedRelease": false,
"mediaType": "Gurux.Net.GXNet",
"mediaSettings": "<IP>x.x.x.x</IP>\r\n<Port>4059</Port>\r\n",
"useLogicalNameReferencing": false
}

  • 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