I made a program which to show LTE device information. The problem i faced is when trying to display only device name, this error occurs " Object reference not set to an instance of an object."
public void GetInfo()
{
Initialise();
var Info = Get("api/device/information");
LogMessage(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
LogMessage(string.Format("Device name:\n {0}", Info.SelectSingleNode("//response/devicename").InnerText)); //something wrong here?
}
Error :
System.NullReferenceException: Object reference not set to an instance of an object.
at HuaweiRouterTool.HuaweiRouter.GetInfo() in C:\Users\pxc\Desktop\HuaweiRouterTool-master\HuaweiRouter.cs:line 233
at HuaweiRouterTool.Program.DeviceInfo() in C:\Users\pxc\Desktop\HuaweiRouterTool-master\Program.cs:line 41
at HuaweiRouterTool.Program.Main(String[] args) in C:\Users\pxc\Desktop\HuaweiRouterTool-master\Program.cs:line 21
But when i delete "devicename", it displayed all value.
public void GetInfo()
{
Initialise();
var Info = Get("api/device/information");
LogMessage(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
LogMessage(string.Format("Device name:\n {0}", Info.SelectSingleNode("//response").InnerText));
}
what am i doing wrong here?