More in this section

Forums / Developing with Sitefinity / Error, when trying to get images from custom module

Error, when trying to get images from custom module

2 posts, 0 answered
  1. Andrew
    Andrew avatar
    202 posts
    05 Jun 2009
    06 Dec 2012
    Link to this post
    I am trying to create a list of images that have been attached to my custom module.
    But getting an error.
    Object reference not set to an instance of an object. (attached)

    I am using the following code to do it:
    model.SelectedEvent = dynamicModuleManager.GetDataItems(wDREventType).Where(i => i.Id == eventId).Where(s => s.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).FirstOrDefault();
                LibrariesManager libraryManager = LibrariesManager.GetManager();
                var imageLinks = (ContentLink[])model.SelectedEvent.GetValue("Images");
                foreach (var imageLink in imageLinks)
                    var image = libraryManager.GetImage(imageLink.ChildItemId);
                    //add new item to list
                return View("Default", model);

    I got this code from Gabe's seminar. So i thought it would work.
    But it does not.
    Any idea of what is going on here?
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    30 Oct 2017
    11 Dec 2012
    Link to this post
    Hello Andrew,

    The described behavior is indeed strange, as we discussed in the support ticket you had open on the same topic, stepping through the code might help us get a better idea of the cause for this problem, or if you could provide us with the complete stack trace that would also be helpful.

    Would it be possible, as a means for the faster resolution of this issue, to send us a sample project where the problem reproduces, so we can tests it locally and give you a more specific advice, or verify whether this is not an issue on our side that needs to be addressed?

    Thank you in advance.

    All the best,
    Boyan Barnev
    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
2 posts, 0 answered