NullReference exception when trying to get CGImageSource properties for a .eps file

danipendanipen USMember ✭✭
edited November 2018 in Xamarin.iOS

Hi, I'm trying to get the image properties for a .eps file, and I'm getting the following NullReferenceException:

Value cannot be null. 
Parameter name: dictionary

        at Foundation.DictionaryContainer..ctor (Foundation.NSDictionary dictionary) [0x00010] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.0.0.0/src/Xamarin.Mac/Foundation/DictionaryContainer.cs:56
        at CoreGraphics.CGImageProperties..ctor (Foundation.NSDictionary dictionary) [0x00000] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.0.0.0/src/Xamarin.Mac/CoreGraphics/CGImageProperties.cs:60
        at ImageIO.CGImageSource.GetProperties (ImageIO.CGImageOptions options) [0x00001] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.0.0.0/src/Xamarin.Mac/ImageIO/CGImageSource.cs:289

Attached there is a .eps file that reproduces the issue.

Any help would be appreciated.

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    Can you post your code?

  • danipendanipen USMember ✭✭
    edited November 2018

    Sure!

                internal static string GetProperties(NSUrl url)
                {
                    using (CGImageSource imageSource = CGImageSource.FromUrl(url))
                    {
                        if (imageSource == null)
                            return string.Empty;
    
                        CoreGraphics.CGImageProperties properties =
                            imageSource.GetProperties();
    
                         return ConverToString(properties);
                    }
                }
    
Sign In or Register to comment.