System.NullReference Exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rama Jayapal
    New Member
    • Mar 2007
    • 24

    System.NullReference Exception

    i have written the following code to call a method in a class like

    in the aspx.cs page
    List<string> surls = new List<string>();

    Cweb.GetMainUrl s(document,ref surls);
    Response.Write( surls);


    in the Cweb Class page the coding is like

    public static void GetMainUrls(Htm ldocument doc,ref List<string> urls)
    {
    //Some functionalities
    }

    i get the following error when i run the application like

    System.NullRefe rence Exception
    object reference not set to an instance

    so because of this error my method is not getting called from the class and hence no result

    can anyone help me out in finding like why my method was not called

    i google through several sites and found that
    this may be due to the fact that the "surls" are null and hence the method was not called
    i dont follow these sequence

    so anybody plz help me on this regard
    thanks
    Rama
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    This exception is probably being thrown inside GetMainUrls(). Put a check in place the handle a null value for urls, and initialize any null strings inside urls before proceeding with the function.

    Comment

    Working...