none
bug in my code : object reference not set an instance of an object

    Question

  •  

    foreach (var elem in this.ParentOfType<frmBasePage>().Panel.Children) { if (bok) { idx++; } if (elem is CDetail) { bok = false; } }

    //this code provide this error object reference not set an instance of an object "this.ParentOfType<frmBasePage>().Panel.children

    • Edited by MDGHAIES Tuesday, April 4, 2017 12:57 PM
    Tuesday, April 4, 2017 12:55 PM

All replies

  • It means some part of the line "this.ParentOfType<frmBasePage>().Panel.Children" is returning a null.

    My guess is that it is the "ParentOfType<frmBasePage>()" part. Presumably there is no parent of that type and so the method returns null.

    Tuesday, April 4, 2017 1:26 PM