Object reference not set to an instance of an object. in Des

Posted by Community Admin on 03-Aug-2018 19:55

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

All Replies

Posted by Community Admin on 26-Apr-2011 00:00

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).

Posted by Community Admin on 27-Apr-2011 00:00

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?

Posted by Community Admin on 27-Apr-2011 00:00

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


Posted by Community Admin on 27-Apr-2011 00:00

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

Posted by Community Admin on 27-Apr-2011 00:00

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

Posted by Community Admin on 27-Apr-2011 00:00

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.

Posted by Community Admin on 27-Apr-2011 00:00

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.

Posted by Community Admin on 27-Apr-2011 00:00

You sir, are an evil genius!   Thank you very much for the help.  Seems to have fixed my prob.

Anthony

Posted by Community Admin on 28-Apr-2011 00:00

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

Posted by Community Admin on 28-Apr-2011 00:00

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

Posted by Community Admin on 28-Apr-2011 00:00

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.

Posted by Community Admin on 28-Apr-2011 00:00

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.

Posted by Community Admin on 28-Apr-2011 00:00

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!

Posted by Community Admin on 28-Apr-2011 00:00

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

Posted by Community Admin on 28-Apr-2011 00:00

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

Posted by Community Admin on 28-Apr-2011 00:00

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

Posted by Community Admin on 28-Apr-2011 00:00

We created a support ticket. If it gets issued a PITS ID, We will let you know what it is.

Posted by Community Admin on 28-Apr-2011 00:00

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.

Posted by Community Admin on 28-Apr-2011 00:00

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.

Posted by Community Admin on 27-Jul-2011 00:00


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.

Posted by Community Admin on 27-Jul-2011 00:00

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

Posted by Community Admin on 27-Jul-2011 00:00

Hi,

It is Sitefinity 4.0.1098.0 SE version. Thanks for your reply.

Posted by Community Admin on 27-Jul-2011 00:00

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

Posted by Community Admin on 27-Jul-2011 00:00

Can you please tell me how to update it on a shared or dedicated server hosting?

Posted by Community Admin on 27-Jul-2011 00:00

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

Posted by Community Admin on 05-Sep-2011 00:00

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. 

Posted by Community Admin on 28-May-2013 00:00

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

Posted by Community Admin on 31-May-2013 00:00

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

Posted by Community Admin on 19-Jun-2013 00:00

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

Posted by Community Admin on 20-Jun-2013 00:00

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

Posted by Community Admin on 07-Mar-2014 00:00

Hello Lilia,

We end up recreating the page with problems, there is a partial workaround is to unpublish, unlock the page and sometimes the error goes away, however I have not seen this for a while. Can you tell us how to dump our complete error log to a file so I can send it to you?

 Thanks

Posted by Community Admin on 12-Mar-2014 00:00

Hi Angel,

unless you have not set some custom logging, you can find the Error.log files in your project's App_Data\Sitefinity\Logs folder.

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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed