We recently updated our development web site from Sitecore CMS 6.6 to Sitecore CMS 7.2. Upon doing so, we lost the ability to load any page on the site that contains an image (almost all of them!), returning the stack trace error:
[MissingMethodException: Method not found: 'System.String Sitecore.Data.Fields.ImageField.get_Src()'.]
[TargetInvocationException: Property accessor 'ImgURL' on object 'Siteworx.Domain.Modules.HomeCarousel' threw the following exception:'Method not found: 'System.String Sitecore.Data.Fields.ImageField.get_Src()'.']
Now currently, the code that we have that is supposed to generate the Image URL (and was working up until the update) is as follows:
public string ImgURL
{
get { return new SCTypes.Image(this, "image").URL; }
}
I am having problems with figuring out what is going wrong here, and have, thus far, had little luck finding any decent references on this issue. If someone could please pull me in the right direction, I would be forever appreciative.
UPDATE - 8/20/2014
Okay,
So I updated the above code to:
public string ImgURL
{
//get { return new SCTypes.Image(this, "image").URL; }
get
{
string src = string.Empty;
Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
Sitecore.Data.Items.Item HomeCarousel = master.GetItem("/sitecore/content/modules/home/carousel items");
Sitecore.Data.Fields.ImageField imageField = HomeCarousel.Fields["imagefield"];
if (imageField != null && imageField.MediaItem != null)
{
Sitecore.Data.Items.MediaItem image = new Sitecore.Data.Items.MediaItem(imageField.MediaItem);
src = Sitecore.StringUtil.EnsurePrefix('/', Sitecore.Resources.Media.MediaManager.GetMediaUrl(image));
// src = Sitecore.Resources.Media.MediaManager.GetMediaUrl(image);
}
return src;
}
And the page now loads, but without images. When viewing the html for where the image should be, I see:
<img src = "">
Which means that the URL for the image is not getting set within the IF Statement. When I try build the code without the IF Statement and load the page, StackTrace pulls back a null reference error.