warning CS0618: 'umbraco.cms.businesslogic.media.Media' is obsolete: 'Obsolete, Use Umbraco.Core.Models.Media
After upgrading from Umbraco 4.7.2 to 6.1.6, compiling code with:
Media media = new Media(mediaId.Value);
generates the warning (above).
But the advice to "Use Umbraco.Core.Models.Media" is not possible because all the constructors have incompatible signatures. They all start with string and also require additional parameters:
public Media(string name, IMedia parent, IMediaType contentType)
public Media(s
public Media(string name, int parentId, IMediaType contentType)tring name, IMedia parent, IMediaType contentType, PropertyCollection properties)
public Media(string name, int parentId, IMediaType contentType, PropertyCollection properties)
warning CS0618: 'umbraco.cms.businesslogic.media.Media' is obsolete: 'Obsolete, Use Umbraco.Core.Models.Media
After upgrading from Umbraco 4.7.2 to 6.1.6, compiling code with:
Media media = new Media(mediaId.Value);
generates the warning (above).
But the advice to "Use Umbraco.Core.Models.Media" is not possible because all the constructors have incompatible signatures. They all start with string and also require additional parameters:
public Media(string name, IMedia parent, IMediaType contentType)
public Media(s
public Media(string name, int parentId, IMediaType contentType)tring name, IMedia parent, IMediaType contentType, PropertyCollection properties)
public Media(string name, int parentId, IMediaType contentType, PropertyCollection properties)
Hi
the warning isn't (quite) pointing you in the right direction.
in the new API you use the MediaService (Umbraco.Core.Services) so to get a mediaitems.
Kevin-
Thanks for the help. I've changed the code from this:
Media media = new Media(mediaId.Value);
return media.getProperty("umbracoFile").Value.ToString();
Now this:
var mediaService = ApplicationContext.Current.Services.MediaService;
Umbraco.Core.Models.IMedia mediaItem = mediaService.GetById(mediaId.Value);
return mediaItem.GetValue("umbracoFile").ToString();
Thanks again!!!!
is working on a reply...