C# Null Reference Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tomngi
    New Member
    • Mar 2008
    • 2

    #1

    C# Null Reference Error

    My C# method occasionally (once every few thousand calls) crashes because of a null reference to a stack variable.

    string MyFunc(MyObject obj)
    {
    string s = "select * from " + obj.ToString() + " where a=10";

    return s;
    }

    The null reference is to the string variable s. The object obj looks fine in the debugger, and what is most mysterious is that this happens only once in a blue moon. Anyone got ideas? Is this possibly a .NET 2.0 problem or is there some memory corruption?

    thanks for any help.

    Tom
  • tomngi
    New Member
    • Mar 2008
    • 2

    #2
    I found the problem, it was my bug after all!!

    Apologies to eveyone for spending anytime on this.

    Comment

    Working...