locked
NullReferenceException was unhandled RRS feed

  • Question

  • Hie there,

    I have a problem to solve as above stated. I already try to debug but could't get the line in a good way. can't see which codition is assign null.

    Can anyone help me to sole this problem. The error occur in the line:

    result = test1_1.Initialise

     

    private

     

    void StartReadInlay2()

    {

    // readinlay2.testconfigXML = configXML;

    // this.readinlay2.StartReadInlay2(ref lProcess1_2);

     

    byte[] cSN = new byte[8];

     

    byte[] sw12 = new byte[2];

     

    string strsw12 = "", result = "";

    test1_2 =

    new Initialisation();

    GetConfigInfo(

    ref configXML);

    test1_2.iChipType = GetChipType(cmbChipType.Text.Trim());

     

    //--initialise test

    result = test1_2.Initialise(1, configXML.fnSamSlot, configXML,

    ref cSN, ref lProcess1_2, ref sw12);

    scSN1_2 =

    Hex.ToHexString(cSN);

    strsw12 =

    Hex.ToHexString(sw12);

     

     

    if (strsw12.Equals("0000"))

    errInlay1_2 = result.ToString();

     

    else

    errInlay1_2 = result.ToString() + strsw12;

    lProcess1_2 = 2;

     

     

    if(!errInlay1_2.Equals(""))

    StatusInlay1_2 =

    false;

     

    else

    StatusInlay1_2 =

    true;

    }

    Wednesday, July 28, 2010 9:12 AM

Answers

  • Hi,

    As far as I can determine from the code you supply, there are a number of candidates. The first is the configXml variable, which may be set to null. Any call onto a method or property on configXml would result in the NullReferenceException. Another posibility would be the test1_2 instance itself, but that would be odd, since you create a new instance a few lines earlier. And then of course the ref parameters could be flawed.

    But the more I look at it, I think the configXml is the target to go on. The GetConfigInfo does not ensure that the configXml will hold a value after it has been called. So check on configXml not being null, might help you further.

    Hope this helps
    Meile Zetstra


    http://blogger.xs4all.nl/mzetstra

    • Marked as answer by Alan_chen Monday, August 2, 2010 1:12 AM
    Wednesday, July 28, 2010 10:11 AM
  • Miele is right. I dont see any instatiation either for the configXML which is more your colprit. But the break point at the call and see if it is null.
    • Proposed as answer by bvrwoo_3376 Wednesday, July 28, 2010 3:14 PM
    • Marked as answer by Alan_chen Monday, August 2, 2010 1:12 AM
    Wednesday, July 28, 2010 3:14 PM
  • Hi Yoganash,

     

    I agree with Meile. From the code you supply, NullReferenceException may relate to configXml.

    Set break points to debug, you can find the value in the watch window.

    Would you please tell me whether you have solved your problem?

     

    Hope these helps, if you have any problems, please feel free to let me know.

     

    Best Regards,

    Alan Chen

    ________________________________________

    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by Alan_chen Monday, August 2, 2010 1:12 AM
    Friday, July 30, 2010 1:35 AM

All replies

  • hi,

    why you cannot find a problem expresion/line? it's nondeterministic problem? do you use Visual Studio, break points, etc. to find the problem? maybe this helps you:

    http://www.blackwasp.co.uk/VSBreakpoints.aspx

    http://dotnetperls.com/debugging-1

    if not, please give me more details (stack trace)


    BR, Karol
    Wednesday, July 28, 2010 9:20 AM
  • Hi,

    As far as I can determine from the code you supply, there are a number of candidates. The first is the configXml variable, which may be set to null. Any call onto a method or property on configXml would result in the NullReferenceException. Another posibility would be the test1_2 instance itself, but that would be odd, since you create a new instance a few lines earlier. And then of course the ref parameters could be flawed.

    But the more I look at it, I think the configXml is the target to go on. The GetConfigInfo does not ensure that the configXml will hold a value after it has been called. So check on configXml not being null, might help you further.

    Hope this helps
    Meile Zetstra


    http://blogger.xs4all.nl/mzetstra

    • Marked as answer by Alan_chen Monday, August 2, 2010 1:12 AM
    Wednesday, July 28, 2010 10:11 AM
  • Miele is right. I dont see any instatiation either for the configXML which is more your colprit. But the break point at the call and see if it is null.
    • Proposed as answer by bvrwoo_3376 Wednesday, July 28, 2010 3:14 PM
    • Marked as answer by Alan_chen Monday, August 2, 2010 1:12 AM
    Wednesday, July 28, 2010 3:14 PM
  • Hi Yoganash,

     

    I agree with Meile. From the code you supply, NullReferenceException may relate to configXml.

    Set break points to debug, you can find the value in the watch window.

    Would you please tell me whether you have solved your problem?

     

    Hope these helps, if you have any problems, please feel free to let me know.

     

    Best Regards,

    Alan Chen

    ________________________________________

    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    • Marked as answer by Alan_chen Monday, August 2, 2010 1:12 AM
    Friday, July 30, 2010 1:35 AM