none
What is a NullReferenceException, and how do I fix it? RRS feed

  • Question

  • Hello I am Facing serious issue with Null reference Expection , i have same executable Code  version in Different machine , then development environment  , i am not getting any issues in development environment but , in End users PC ( only in Few PC) i am getting this error .

    May be Usage of Linq ( extension in  way like ...) 

    I Have refereed this link but not really helpful.

    http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it

    Major question why its  showing expection in only few PC not every machice 

     More info:

    I am using DataTable Collection and DataRows 

    Linq on them!.

    Usage of Merge and Clone etc..

    Thanks 

    Ranjith  Murthy 


    Ranjith@Learner @Microsoft products

    Friday, August 19, 2016 3:10 PM

Answers

  • Since there's no source code provided we can just provider some wild guess.

    Based on the name of function, It seems to be some sort of unit test "Setup" method that sets the stage for the tests. Maybe you have problem connecction to target database, or have no permission to truncate / drop and create / modify the tables in the "verdict" database?

    Monday, August 22, 2016 1:31 AM
    Answerer

All replies

  • From the error you should be able to track down the section of code that is causing the error.

    In general, it means you are using an object that you expect to have a value but which is, in fact, null.

    For example:

    // Function that you expect to return a SomeClass object, but which in fact returns null
    SomeClass c = GetMyClass();
    
    c.DoSomething(); // c is null. This throws NullReferenceException!

    So you need to look at your code, trace it through, and determine what object may be null. The fact that it only happens on some PCs and not others means there is obviously something different on those PCs, such as configuration, data etc. And this difference is causing your code to end up with a null object somewhere.

    If you're still not sure, make sure you have tracked down the appropriate bit of code that is throwing the exception and post it up here!


    • Edited by RJP1973 Friday, August 19, 2016 4:27 PM
    Friday, August 19, 2016 4:26 PM
  • Thanks for your reply but , I am using same code in developement machice its completely fine my machice i dont know whats wrong with other PC

    Ranjith@Learner @Microsoft products

    Friday, August 19, 2016 7:55 PM
  • Since there's no source code provided we can just provider some wild guess.

    Based on the name of function, It seems to be some sort of unit test "Setup" method that sets the stage for the tests. Maybe you have problem connecction to target database, or have no permission to truncate / drop and create / modify the tables in the "verdict" database?

    Monday, August 22, 2016 1:31 AM
    Answerer