Object reference not set to an instance of an object

Posted by Community Admin on 04-Aug-2018 10:24

Object reference not set to an instance of an object

All Replies

Posted by Community Admin on 25-Mar-2013 00:00

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?








 

Posted by Community Admin on 25-Mar-2013 00:00

If those values are null, you could be running into issues calling .toString() on them.

Posted by Community Admin on 26-Mar-2013 00:00

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: 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 go.microsoft.com/.../events.asp.

Posted by Community Admin on 26-Mar-2013 00:00

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

Posted by Community Admin on 26-Mar-2013 00:00

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.

www.sitefinity.com/.../migration-of-development-source-code-to-another-computer

This thread is closed