More in this section

Forums / General Discussions / MediaUrl is null

MediaUrl is null

8 posts, 0 answered
  1. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    05 Apr 2012
    Link to this post
    MediaUrl throws exception - This is not a natural development experience.
    I am retrieving the album and then I try to get the media url and it throws an exception. I am trying to bind a list of images from an album to a listview. Let me know what I am doing wrong.
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    05 Apr 2012
    Link to this post
    Hi Jaime, are you attempting to do this programmatically via the API? Can you provide me with a sample of the code you are attempting to run?

    Also, what specific exception are you getting?
  3. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    05 Apr 2012
    Link to this post
    var manager = new LibrariesManager();
    var album    = manager.GetAlbums().FirstOrDefault();
    if (album != null)
        DataSource = album.Images.Take(4).ToList();
     
    ProjectImagesListView.DataSource = DataSource;
  4. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    05 Apr 2012
    Link to this post
    Object reference not set to an instance of an object
  5. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    05 Apr 2012
    Link to this post
    on what line are you getting the exception? does the album return null as well?
    I haven't yet tried your code, however looking at it can you try changing the first line  new LibrariesManager() to
    var manager = LibrariesManager.GetManager()

    this is the preferred method for instantiating the manager as it uses the Default provider.

    let me know if that makes any difference
  6. Jaime Weise
    Jaime Weise avatar
    120 posts
    Registered:
    02 Nov 2008
    05 Apr 2012
    Link to this post
    only the mediaurl returns null
  7. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    12 Apr 2012
    Link to this post
    Jaime, sorry about the delay in following up on this. it took me some time to recreate the issue.

    It appears this may be due to a change in the Url implementation in 5.0. Instead of referencing the Url property directly, there appears to be a ItemDefaultUrl property instead that seems to correctly refer to it.

    The Urls array appears to now be populated, so alternatively you can do image.Urls[0].Url

    hope this is helpful!
  8. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    13 Apr 2012
    Link to this post
    I had the same issue recently. It used to work but it just stoped giving me the MediaUrl. So had to rework the code.
8 posts, 0 answered