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

Forums / General Discussions / Object reference not set to an instance of an object. in Design/Template

Object reference not set to an instance of an object. in Design/Template

32 posts, 0 answered
  1. JP
    JP avatar
    7 posts
    Registered:
    03 Feb 2011
    26 Apr 2011
    Link to this post
    Hi
    As we have encountred a serious problem with our pages ( pages showing old widgets that ahev been deleted before)
    I had to redo ALL PAGES with no template !! waiting the bug fix.

    I 've worked all the weekend to complete them, and now I wanted to add new template to be able to test my pages : Big surprise :  I can't and I get the message : Object reference not set to an instance of an object.

    I have checked in the table sf_Page_Template and all my templates are there.

    I am suspecting this is because of the culture since all my new pages are in FR-CA, but I tried to change the both languages (frontend end and backend to ENG-US, FR , FR-CA) with no luck.

    1- Any idea How this could be fixed,
    2- Is there a way to create new clean project and copy all my pages and content to the new project, I can afford redo the template but not the pages (180 pages).
  2. Augus
    Augus avatar
    34 posts
    Registered:
    29 Mar 2011
    27 Apr 2011
    Link to this post
    HI JP, are you using custom master page? i had this issue too before. here's my fix

    add runat="server" in head tag

    <head runat="server">

    secondly add form and script manager inside the body

    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
     
    .....
     
    </form>
    </body>

    hopefully this can can help and maybe someone from telerik can explain more?
  3. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    27 Apr 2011
    Link to this post
    Hello JP,

    My colleague Sonya Panayotova answered you in the support ticket you have opened. If there are further questions we can keep the discussion in the support thread.

    Regards,
    Victor Velev
    the Telerik team

  4. Anthony
    Anthony avatar
    108 posts
    Registered:
    29 Sep 2008
    27 Apr 2011
    Link to this post
    Any chance of finding out what the solution provided in the support ticket was/is or if it worked.  i just upgraded from 4.0 to 4.1 and running into what I think is the same thing.

    I cant even get a return of the templates that have been created or an option to create a new template.  I just get "Object reference not set to an instance of an object." when i click on Page Templates.

    Thanks.

    Anthony
  5. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    27 Apr 2011
    Link to this post
    We experienced the exact same issue.  This morning, we started getting the same error, (object reference not set to instance of an object), we were able to identify and correct what was causing it.

    Login to the database and run this query:
    SELECT *
    FROM    dbo.sf_page_templates a
    INNER JOIN dbo.sf_draft_pages b
    ON      a.id = b.template_id
            AND b.is_temp_draft = 0
    INNER JOIN dbo.sf_page_data c
    ON      b.page_id = c.content_id
    WHERE   NOT EXISTS ( SELECT 1
                         FROM   dbo.sf_page_node x
                         WHERE  x.content_id = c.content_id )

    If you get any results, then you have the same issue we did. 

    Tom
  6. Anthony
    Anthony avatar
    108 posts
    Registered:
    29 Sep 2008
    27 Apr 2011
    Link to this post
    I get one row returned using your Query. 
    Does this row need to be deleted or any other action taken?  After running I am still getting the error.
  7. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    27 Apr 2011
    Link to this post
    OK,

    Yes, you will need to delete it. The pages you delete will need to be recreated, so take note of what you delete.

    You run this at you own risk. This is what we did to fix it, but make SURE you back up the database before you do this.

    Run this SQL:
    DELETE  a
    FROM    dbo.sf_draft_pages a
    WHERE   a.page_id IS NULL
            OR NOT EXISTS ( SELECT  1
                            FROM    dbo.sf_page_data x
                            WHERE   x.content_id = a.page_id )

    then run this SQL:
    SELECT  'DELETE FROM sf_draft_pages WHERE id = ''' + CAST(b.id AS VARCHAR(50)) + '',
            'DELETE FROM sf_page_data WHERE id = ''' + CAST(b.page_id AS VARCHAR(50)) + ''
    FROM    dbo.sf_page_templates a
    INNER JOIN dbo.sf_draft_pages b
    ON      a.id = b.template_id
            AND b.is_temp_draft = 0
    INNER JOIN dbo.sf_page_data c
    ON      b.page_id = c.content_id
    WHERE   NOT EXISTS ( SELECT 1
                         FROM   dbo.sf_page_node x
                         WHERE  x.content_id = c.content_id )

    Copy the Delete statements generated from the second SQL and past it in another query window and run it.

    That took care of it for us.
  8. Anthony
    Anthony avatar
    108 posts
    Registered:
    29 Sep 2008
    27 Apr 2011
    Link to this post
    You sir, are an evil genius!   Thank you very much for the help.  Seems to have fixed my prob.

    Anthony
  9. JP
    JP avatar
    7 posts
    Registered:
    03 Feb 2011
    28 Apr 2011
    Link to this post
    Hi
    In my support ticket SF guys sent me a SQL script but didn't solve my problem.

    I have started a new project from scratch because my project was updated and patched several times and i want to start upon clean bases. 

    @Anthony  But, still I tried your solution and it worked.

    Cheers
  10. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    28 Apr 2011
    Link to this post
    I am glad to see that it works for others as well. Too bad we didn't get a solution in time for it to really benefit you. 

    There is a bug somewhere in Sitefinity that is causing this.  I am not sure what it is, but whatever it is, we may see it again in the future. At least we will know what to do if it happens again.

    Tom
  11. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    28 Apr 2011
    Link to this post
    Thanks for the scripts and ideas Thomas.  I have a support ticket in which I will still see what they tell me, but I made sure I had a backup and tried this for fun.  Based on the results I think I can help us pinpoint how this bug was triggered at least for me.

    I ran your first query and got 2 rows back.  Each was using a different template, but what I noticed is that the pages in question where group pages.  I know for a fact that when I first created the pages I had them as normal pages and had content on them for testing.  At some point my client came back to me asking that we use drop downs.  I remember changing them via Titles & Properties and I am guessing that the content that was on them got orphaned somehow.

    At least now I can access my design templates again.  I might test this out more to see if I can break it again though.
  12. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    28 Apr 2011
    Link to this post
    I just confirmed what my last post said.  I took another normal page that had content on it and I went into titles and properties and changed it to a group page.  Went back to view page templates and it blew up with the same error.
  13. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    28 Apr 2011
    Link to this post
    That's great news! We have several other developers creating templates and pages. Since I had nothing to do with the action that caused the issue, I had no idea how to reproduce it. 

    Good detective work. Mystery solved!
  14. Anthony
    Anthony avatar
    108 posts
    Registered:
    29 Sep 2008
    28 Apr 2011
    Link to this post
    I just went back to confirm this because it just happened to me again and saw your post.  I upgraded another site from 4.0 to 4.1 today and noticed that when I had to change a page from a regular page to a group page that I started getting this error for page templates. 

    I have done it now twice and get the same result both times.  This is definitely a bug. 

    Since Thomas found the fix/workaround I think Telerik should hook him up with some points or a t-shirt or something!

    I haven't seen the issue reported to PITS yet, has anyone else?

    Anthony
  15. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    28 Apr 2011
    Link to this post
    Now that we know what is causing the issue, I think there is a much better fix that deleting records out of the database. We are going to try something. I will post the results of our test and possibly a better fix.

    Stay tuned.

    Tom
  16. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    28 Apr 2011
    Link to this post
    OK,

    We still need to delete from the sf_draft_pages table, but other than that, we just update the template_id back to the default zeros.

    This should fix the issue in a more elegant fashion without lossing data:
    UPDATE  dbo.sf_page_data
    SET     template_id = '00000000-0000-0000-0000-000000000000'
    WHERE   NOT EXISTS ( SELECT 1
                         FROM   dbo.sf_page_node x
                         WHERE  x.content_id = dbo.sf_page_data.content_id )
            AND template_id != '00000000-0000-0000-0000-000000000000'
     
    DELETE  a
    FROM    dbo.sf_draft_pages a
    WHERE   NOT EXISTS ( SELECT 1
                         FROM   dbo.sf_page_node x
                         WHERE  x.content_id = a.page_id )


    BTW, I can't take the credit for this.  Chris Hansen is the real guru.

    Tom
  17. Tom
    Tom avatar
    37 posts
    Registered:
    26 Apr 2006
    28 Apr 2011
    Link to this post
    We created a support ticket. If it gets issued a PITS ID, We will let you know what it is.
  18. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    28 Apr 2011
    Link to this post
    Has anyone confirmed if they can actually make changes to the templates and see them reflected?  I have tried removing items and adding content items to the template and publishing it.  The template itself looks good, but the pages using the template are not showing these new changes.

    I tried re-compiling the solution, resetting browser cache, recycling the application pool and it does not seem to do anything.  Just wondering if this is still part of this issue or something entirely new.
  19. Stacey
    Stacey avatar
    291 posts
    Registered:
    18 Oct 2012
    28 Apr 2011
    Link to this post
    Maybe this is how is has always been and I just haven't noticed until now, but if I re-publish all the pages that were already assigned to the template they will show the new updates to that template.
  20. King Rajpoot
    King Rajpoot avatar
    20 posts
    Registered:
    28 Oct 2009
    27 Jul 2011
    Link to this post

    I faced the same issue, Here are the steps that causes it to happen on my end.
    I have a published page with multiple languages
    then i have changed the templates for two languages and these are saved as drafts (by default).
    I did not publish them.
    After sometime, I tried to open template page and got this error.

    It was a test page so I just deleted that page and it starts working.

  21. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    27 Jul 2011
    Link to this post
    Hi,

    Have you succeeded in replicating the issue using our latest version of Sitefinity - 4.1. SP3 or you have used 1339? The issue was fixed in the release after 1339.

    Kind regards,
    Victor Velev
    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
  22. King Rajpoot
    King Rajpoot avatar
    20 posts
    Registered:
    28 Oct 2009
    27 Jul 2011
    Link to this post
    Hi,

    It is Sitefinity 4.0.1098.0 SE version. Thanks for your reply.
  23. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    27 Jul 2011
    Link to this post
    Hello,

    Please update to our latest version as they are many bugs fixed from the initial builds and a lot of new features added.

    Greetings,
    Victor Velev
    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
  24. King Rajpoot
    King Rajpoot avatar
    20 posts
    Registered:
    28 Oct 2009
    27 Jul 2011
    Link to this post
    Can you please tell me how to update it on a shared or dedicated server hosting?
  25. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    27 Jul 2011
    Link to this post
    Hi,

    You can replace all the dlls in the bin folder of Sitefinity with those from a newer version or you can download your project codebase & database, set it up locally and perform the upgrade using the Project Manager. I can suggest you to use the second approach because you can always revert back to a backup version of the site if something goes wrong.

    Best wishes,
    Victor Velev
    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
  26. Tom Miller
    Tom Miller avatar
    52 posts
    Registered:
    27 Feb 2010
    05 Sep 2011
    Link to this post
    Thanks works great.  I also played around with a "group" page just last week.  Never ended up using it. Templates was working fine before then. 
  27. Angel
    Angel avatar
    6 posts
    Registered:
    01 Apr 2013
    28 May 2013
    Link to this post
    Hey guys, 

    Just FYI this is still happening on Sitefinity 6.0. Any suggestions? We are live and don't want to cut our templates, yes two of them got an invalid GUID 00000000-0000-0000-0000-000000000000 on personalization_segment_id , personalization_master_id, locked_by, original_content_id and last_modified_by, 

    Sincerely

    Angel
  28. Boyko Nistorov
    Boyko Nistorov avatar
    16 posts
    Registered:
    17 Oct 2016
    31 May 2013
    Link to this post
    Hi Angel,

    Setting Guid.Empty value in some fields is not necessary a problem. In your case you should not be worried about this. It is managed case.

    Regards,
    Boyko Nistorov
    Telerik
    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
  29. Angel
    Angel avatar
    6 posts
    Registered:
    01 Apr 2013
    19 Jun 2013 in reply to Boyko Nistorov
    Link to this post
    Hi Boyko.

    This was preventing our users to modify, create and update pages that were using the template with Guid.Empty value. Any workaround for this?

    Angel
  30. Lilia Messechkova
    Lilia Messechkova avatar
    42 posts
    Registered:
    13 Jul 2016
    20 Jun 2013
    Link to this post
    Hi Angel,

    Can you please give us more details on what is the error which you receive when you try to create or update a page with these templates. It will be very helpful if you can send us the error log.

    Regards,
    Lilia Messechkova
    Telerik
    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
32 posts, 0 answered
1 2