Very disappointed for error Object reference not set to an instance of an object.
I've a big problem with UBlogsy package on U6.1.6 amd I lose a lot of time to understand why!
Is't a UBlogsy or Umbraco bug?
Every time that I open a post, a landing page, the server goes in error with:
Object reference not set to an instance of an object.
Line 47: // show each post
Line 48: foreach (var n in posts)
Line 49: {
Line 50: @Html.Partial("uBlogsy/Landing/uBlogsyLandingShowPost", new ViewDataDictionary(ViewData) { { "Node", n }, { "GravatarSize", 40 }, { "ImageWidth", 300 }, { "ImageHeight", -1 } })
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.<get_GetXmlDelegate>b__2(UmbracoContext context, Boolean preview) +84
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetById(UmbracoContext umbracoContext, Boolean preview, Int32 nodeId) +36
Umbraco.Web.PublishedCache.ContextualPublishedCache`1.GetById(Boolean preview, Int32 contentId) +40
Rebuilding the examine indexes after an app restart might also regen the xml cache. Unless there's something on this line:
foreach (var n in posts)
that is accessing the media cache - which does use Examine?
There's nothing in this stack trace to indicate this is an Examine or index problem. However, it does look like a problem someplace with the XML cache and IPublishedContent.
This is my first post. I just wanted to share my solution to this problem! Actually, this problem occurs when the application tries to convert array of Examine.SearchResult to IPublishedContent.
There are 4 files that you have to change in order to uBlogsy to work fine:
uBlogsyLandingListPosts.cshtml
uBlogsyPostListRelatedPosts.cshtml
uBlogsyWidgetListPosts.cshtml
uBlogsyWidgetListPostsForHome.cshtml
As an example I have chosen uBlogsyLandingListPosts.cshtml:
Change this
var posts = PostService.Instance.GetPosts(Model.Content, tag, label, author, searchTerm, commenter, year, month, day, out postCount).Skip((page - 1) * itemsPerPage).Take(itemsPerPage).ToIPublishedContent(true);
To this:
var posts = PostService.Instance.GetPosts(Model.Content, tag, label, author, searchTerm, commenter, year, month, day, out postCount).Skip((page - 1) * itemsPerPage).Take(itemsPerPage);
//.ToIPublishedContent(true);
Then change the data type of parameter's IEnumerable from IPublishedContent to Examine.SearchResult.
Do you mean the bug when you have an unpublished news item and the site reports an error? If yes, then you have to modify a few things more. I am not at work right now, so I do not have the code at hand, but, perhaps, tomorrow I will be able to post a comment about fixing it.
It just checks if this node has content published (in case of not published news) and if the parent node is published (in case of the day is not published). Because it usually happens, when you publish the news node and folders, such as year, month and day don't get published.
I'd just like to say thanks to the guys on this thread, it helped me solve my issue of "Object reference not set to an instance of an object." after deploying my site in VS2013.
After deployment I had this error, the debug info indicated that the Html object on my homepage was null! For me it was a case of corrupt Examine Indexes. Deleted /App_Data/TEMP/ExamineIndexes/* and everything rebuilt fine!
I just wanted to say thanks anyway because my bug was caused by an ExamineIndexes corruption, which was discussed earlier in the thread. It seems my specific issue is more an Umbraco deployment thing, not just something that can effect your package.
Very disappointed for error Object reference not set to an instance of an object.
I've a big problem with UBlogsy package on U6.1.6 amd I lose a lot of time to understand why!
Is't a UBlogsy or Umbraco bug?
Every time that I open a post, a landing page, the server goes in error with:
Object reference not set to an instance of an object.
Line 47: // show each post Line 48: foreach (var n in posts) Line 49: { Line 50: @Html.Partial("uBlogsy/Landing/uBlogsyLandingShowPost", new ViewDataDictionary(ViewData) { { "Node", n }, { "GravatarSize", 40 }, { "ImageWidth", 300 }, { "ImageHeight", -1 } })
Source File: c:\HostingSpaces\xyzv\dfgt\wwwroot\Views\Partials\uBlogsy\Landing\uBlogsyLandingListPosts.cshtml Line: 48
Stack Trace:
This sounds like file permissions:
http://our.umbraco.org/wiki/reference/files-and-folders/permissions
Ensure that the hosting environment is Full Trust
Verify that it works on your local machine, and that ALL files are deployed.
Verify that /app_data/umbraco.config is updated when you publish from the backoffice.
Hi,
all permissions are ok. I see that umbraco.config is updated when I publish. Full Trust is active.
I see if I remove umbraco.config and Examine indexes under TEMP, I see posts.
I disable <uLoremsy> <tree nodeName="*" enabled="false">
So it is working?
If so, it could have been corrupt examine indexes.
So it is working?
If so, it could have been corrupt examine indexes.
I tried to play with content and I have not the error until now.
So, for other people:
- remove umbraco.config and all index files under TEMP\Examine\<folders>
Why Indexes Will be corrupted?
I have no idea why the indexes get corrupted. All I know is that from time to time that's a cause of major pain.
Good to hear you solved your problem though.
I'm afraid, but the problem is still there!
I think that there is some bug on Examine...
Turn off your app, then delete the examine indexes.
Check if that they are regenerated and everything is working.
If things stop working after that then I think it's likely a permission issue. Is this local (laptop?) or a server? Is the server loadbalanced?
No, I tried that before and indexes are regenerated into their folder. It's on the server and not loadbalanced.
The error is coming from:
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.
This doesn't use Examine at all.
Rebuilding the examine indexes after an app restart might also regen the xml cache. Unless there's something on this line:
foreach (var n in posts)
that is accessing the media cache - which does use Examine?
There's nothing in this stack trace to indicate this is an Examine or index problem. However, it does look like a problem someplace with the XML cache and IPublishedContent.
Can you provide steps to replicate this problem?
The problem continue. It's reported by other users,too.
The cache problem is still here. Is't possibile to disable uBlogsy to use Examine or it's a core problem????
I report here the error: http://issues.umbraco.org/issue/U4-4334
Hi
This is probably not the ideal solution, but you could wrap the code in a try-catch. This will at least stop the crash.
try{
var posts = PostService.Instance.GetPosts(Model.Content, tag, label, author, searchTerm, commenter, year, month, day, out postCount).Skip((page - 1) * itemsPerPage).Take(itemsPerPage).ToIPublishedContent(true);
//var posts = NoLuceneFallbackService.Instance.GetPosts(Model.Content.Id, tag, label, author, searchTerm, commenter, year, month, out postCount).Skip((page - 1) * itemsPerPage).Take(itemsPerPage);
// pagination
@RenderPagination(page, postCount, itemsPerPage)
@RenderForLanding(posts)
}
catch(Exception ex){}
Hi everyone,
This is my first post. I just wanted to share my solution to this problem! Actually, this problem occurs when the application tries to convert array of Examine.SearchResult to IPublishedContent.
There are 4 files that you have to change in order to uBlogsy to work fine:
As an example I have chosen uBlogsyLandingListPosts.cshtml:
Change this
To this:
Then change the data type of parameter's IEnumerable from IPublishedContent to Examine.SearchResult.
Change to this:
And finally, take each node's id and get this node's IPublishedContent:
And that's it. Solved my problem and all is working now. Integrating it with my website at the moment.
Good luck to all!
Best regards, Alex
Thanks, Aleksey!
Your solution works great.
Hi,
Have you tried if "publish at" work with this work around?
Hi Biagio,
Do you mean the bug when you have an unpublished news item and the site reports an error? If yes, then you have to modify a few things more. I am not at work right now, so I do not have the code at hand, but, perhaps, tomorrow I will be able to post a comment about fixing it.
Best regards,
Alex
Hi Biagio,
Sorry, I just didn't have the time to post a reply with code. So, this is what I did:
It just checks if this node has content published (in case of not published news) and if the parent node is published (in case of the day is not published). Because it usually happens, when you publish the news node and folders, such as year, month and day don't get published.
Hope this helps.
Best regards,
Alex
I'd just like to say thanks to the guys on this thread, it helped me solve my issue of "Object reference not set to an instance of an object." after deploying my site in VS2013.
After deployment I had this error, the debug info indicated that the Html object on my homepage was null! For me it was a case of corrupt Examine Indexes. Deleted /App_Data/TEMP/ExamineIndexes/* and everything rebuilt fine!
Many thanks,
Danny "Blatant"
Hi,
Danny try to upgrade to last version of UBlogsy. It solve some bugs ( like null error wrote in this post ) and compliance with 6.2.x.
Thanks Biagio, But I am not using uBlogsy! :D
I just wanted to say thanks anyway because my bug was caused by an ExamineIndexes corruption, which was discussed earlier in the thread. It seems my specific issue is more an Umbraco deployment thing, not just something that can effect your package.
Kind Regards,
Danny "Blatant"
Hi,
I am facing same issue, i have upgraded version of umbraco (version 7.3.0), and uBlogsy(4.1.2).
Strange thing is that, after restarting IIS App pool, its starts working fine. But this is not the solution.
Any one have permanent solution of this issue??
Hi,
Anyone figured a solution to this one yet?
is working on a reply...