An object not set to instance of an object RRS feed

  • Question

  • I am getting an exception 

    An object not set to instance of an object....Where am i going wrong???


    • Edited by MSKR_SharePoint Friday, March 21, 2014 3:33 AM Legal Code Issues
    Thursday, March 20, 2014 5:37 PM


  • Possible points of the error in your code are

    string strTemplateLink = spItem["TemplateUrl"].ToString();
    string[] str = strTemplateLink.Split('/');
    if (strTemplateLink.Contains("http") || strTemplateLink.Contains("https"))
        spItem["TemplateUrl"] = "~sitecollection/FormServerTemplates/" + str[str.Length - 1].ToString();

     Doing spItem["TemplateUrl"].toString() , if spItem["TemplateUrl"] is null can cause. Any operations on string without checking null can be the cause like taking Length of string. Checking Contains etc.

    Best way to solve the issue is do a null check and also try using attaching to w2wp.exe worker process and debugging the code to fix the issue.

    Geetanjali Arora | My blogs |

    Friday, March 21, 2014 2:11 AM