1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Object reference not set to an instance of an object

Object reference not set to an instance of an object

5 posts, 0 answered
  1. Tim
    Tim avatar
    7 posts
    Registered:
    17 Oct 2012
    25 Mar 2013
    Link to this post
    My tasks is to add new fields to an existing controls:
    these are the control that should be added
    ·         Hotbutton text – text field
    ·         Hotbutton URL – text field

    So what I did first is add new fields in Sitefinity
    Administration. please see attached Sitefinity1

    And then add this code (please see attached sitefinity2) to the the class "HomepageFeatures.cs" and 
    Then I have published it and copy and paste to update the existing website

    then the error appears :
    Object reference not set to an instance of an object.



    Description: An unhandled exception occurred during
    the execution of the current web request. Please review the stack trace
    for more information about the error and where it originated in the
    code.





    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.



    Source Error:








    An unhandled exception was generated during the execution of the current
    web request. Information regarding the origin and location of the
    exception can be identified using the exception stack trace below.








    Stack Trace:






    [NullReferenceException: Object reference not set to an instance of an object.]
    SitefinityWebApp.Widgets.HomepageFeatures.HomepageFeatures.InitializeControls(GenericContainer container) +1219
    Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls() +58
    System.Web.UI.Control.EnsureChildControls() +102
    System.Web.UI.Control.PreRenderRecursiveInternal() +42
    System.Web.UI.Control.PreRenderRecursiveInternal() +175
    System.Web.UI.Control.PreRenderRecursiveInternal() +175
    System.Web.UI.Control.PreRenderRecursiveInternal() +175
    System.Web.UI.Control.PreRenderRecursiveInternal() +175
    System.Web.UI.Control.PreRenderRecursiveInternal() +175
    System.Web.UI.Control.PreRenderRecursiveInternal() +175
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496


    Can you tell me what I did wrong?





     
  2. Tim
    Tim avatar
    258 posts
    Registered:
    22 Jun 2011
    25 Mar 2013 in reply to Tim
    Link to this post
    If those values are null, you could be running into issues calling .toString() on them.
  3. Tim
    Tim avatar
    7 posts
    Registered:
    17 Oct 2012
    26 Mar 2013 in reply to Tim
    Link to this post
    hmm....
    i tried this but i still get the error (Please see below). Can you check if I'm missing something from the start.


                    if (String.IsNullOrEmpty(item.GetValue("Hotbuttontext").ToString()))
                    {
                        hotbuttontext = "";
                    }
                    else
                    {
                        hotbuttontext = item.GetValue("Hotbuttontext").ToString();
                    }
                    if (String.IsNullOrEmpty(item.GetValue("HotbuttonURL").ToString()))
                    {
                        hotbuttonURL = "";
                    }
                    else
                    {
                        hotbuttonURL = item.GetValue("HotbuttonURL").ToString();
                    }
    Error:


    Event code: 3005
    Event message: An unhandled exception has occurred.
    Event time: 26/03/2013 11:11:35 AM
    Event time (UTC): 26/03/2013 12:11:35 AM
    Event ID: 0689076d6de447878465f7c2a3fe429f
    Event sequence: 3
    Event occurrence: 1
    Event detail code: 0
     
    Application information:
        Application domain: /LM/W3SVC/1495936340/Root-1-130087302757545382
        Trust level: Full
        Application Virtual Path: /
        Application Path: D:\Domains\Sitefinity\lateralevents\
        Machine name: zeus
     
    Process information:
        Process ID: 5884
        Process name: w3wp.exe
        Account name: NT AUTHORITY\NETWORK SERVICE
     
    Exception information:
        Exception type: NullReferenceException
        Exception message: Object reference not set to an instance of an object.
       at SitefinityWebApp.Widgets.HomepageFeatures.HomepageFeatures.InitializeControls(GenericContainer container)
       at Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls()
       at System.Web.UI.Control.EnsureChildControls()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

     
     
    Request information:
        Request URL: http://development.lateralevents.com/
        Request path: /
        User host address: 192.168.200.4
        User:  
        Is authenticated: False
        Authentication Type:  
        Thread account name: NT AUTHORITY\NETWORK SERVICE
     
    Thread information:
        Thread ID: 1
        Thread account name: NT AUTHORITY\NETWORK SERVICE
        Is impersonating: False
        Stack trace:    at SitefinityWebApp.Widgets.HomepageFeatures.HomepageFeatures.InitializeControls(GenericContainer container)
       at Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls()
       at System.Web.UI.Control.EnsureChildControls()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     
     
    Custom event details:

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
  4. Veselin Vasilev
    Veselin Vasilev avatar
    23 posts
    Registered:
    27 Jul 2015
    26 Mar 2013
    Link to this post
    Hi Tim,

    can you debug locally and see on which line exactly the exception is thrown.

    Also, when you add the columns to the datatable you might want to change the type of the columns to String instead of Int32. 

     

    Regards,
    Veselin Vasilev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Tim
    Tim avatar
    7 posts
    Registered:
    17 Oct 2012
    26 Mar 2013 in reply to Veselin Vasilev
    Link to this post
    Actually I already changed the type to string and that's the latest error i got.
    Btw, I just migrated the source code to my local desktop and my another problem is that i can't make it work. I've already posted another forum to this.

    http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/migration-of-development-source-code-to-another-computer
5 posts, 0 answered