Accessing Image from Library - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Accessing Image from Library

  • Accessing Image from Library
  • Hello -

            Dim manager As LibrariesManager = LibrariesManager.GetManager()
            Dim album = manager.GetAlbums().Where(Function(a) a.Title.Value = "Ads").FirstOrDefault()

    Everywhere I look - this should work, however it always returns the following error...
    Property 'System.String Value' is not defined for type 'System.String'


    any help would be much appreciated.
  • Hi Robert,

    The problem is that Title is of type Lstring, and "Ads" is of type string. VB.NET has a problem with that, even if you use the Value property which is a string. I don't know the details, but you can try this:

    Dim manager As LibrariesManager = LibrariesManager.GetManager()
    Dim album = manager.GetAlbums().Where(Function(a) a.Title.Equals("Ads")).FirstOrDefault()
  • Hi Robert,

    Arno is given the correct solutions. This is a VB.NET thing. While C# allows the comparing of LString with string directly, in VB.NET you have to explicitly complare the Value property of the LString type with the parameter. But that isn't enough apparently.

    Try this code, it works on my side :)
    Public Shared Function GetAlbum(name As String) As Album
       
       Dim manager As LibrariesManager = LibrariesManager.GetManager()
       Dim album = manager.GetAlbums().FirstOrDefault(Function(a) a.Title.Equals(name))
       Return album
      
    End Function

    Kind regards,
    Daniel

    * If this post helped you, please mark it as answered
  • Thanks - that was it!
  • Daniel Plomp said:Hi Robert,

    Arno is given the correct solutions. This is a VB.NET thing. While C# allows the comparing of LString with string directly, in VB.NET you have to explicitly complare the Value property of the LString type with the parameter. But that isn't enough apparently.

    Hi Daniel,

    It's apparently not just a VB.NET thing - I'm trying to do the same sort of thing in C#, and having no luck.

    I try Title=="name", I get an error about comparing LString to String.

    I try Title.Value=="name", I get an error about String not having a Value method. 

    I try Title.Equals("name"), I get no match (even though there is an album with that name).

    I've also tried both GetAlbums().Where(...).FirstOrDefault() and GetAlbums().FirstOrDefault(...) - no difference.

    Here's the current version of my function:

            protected bool ImageExists(string imageName)
           
                try
               
                    LibrariesManager librariesManager = LibrariesManager.GetManager();
                    Album album = librariesManager.GetAlbums().FirstOrDefault(a => a.Title.Equals("Banners"));
                    Image image = null;
                    if (album != null)
                        image = album.Images().FirstOrDefault(i => i.Title.Equals(imageName));
                    return (image != null);
               
                catch (Exception)
               
                    throw;