Error, when trying to get images from custom module

Posted by Community Admin on 04-Aug-2018 05:48

Error, when trying to get images from custom module

All Replies

Posted by Community Admin on 06-Dec-2012 00:00

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
                model.SelectedImageCollection.Add(image);
                 
            
             
            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?

Posted by Community Admin on 11-Dec-2012 00:00

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

This thread is closed