Setting BitmapMetadata.Title in service running on Windows Server 2003 Web Edition throws NotSupportedException

0

So I have this method to set some basic MetaData tags which eventually will be added to my image:

        BitmapMetadata metaData = new BitmapMetadata("jpg");
        foreach (var t in tags)
        {
            try
            {
                switch (t.Key)
                {
                    case "Author":
                        metaData.Author = new System.Collections.ObjectModel.ReadOnlyCollection<string>(new string[] { t.Value });
                        break;

                    case "Rating":
                        int rating = 0;
                        if (int.TryParse(t.Value, out rating))
                        {
                            metaData.Rating = rating;
                        }
                        break;

                    case "Subject":
                        metaData.Subject = t.Value;
                        break;

                    case "Title":
                        metaData.Title = t.Value;
                        break;

                    case "Comment":
                        metaData.Comment = t.Value;
                        break;

                    default:
                        keywords.Add(string.Format("{0}:{1}", t.Key, t.Value));
                        break;
                }
            }
            catch (Exception ex)
            {
                //Do some logging
            }
        }

And I keep getting the error:

System.NotSupportedException: No imaging component suitable to complete this operation was found. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x88982F50 \ --- End of inner exception stack trace --- \ at System.Windows.Media.Imaging.BitmapMetadata.SetQuery(String query, Object value) \ at System.Windows.Media.Imaging.BitmapMetadata.set_Title(String value)

Running as localhost on Windows 8.1 this works fine. As soon as I deploy my service to my Windows Server 2003 Web Edition it throws the shown error. What is happening?

c#
wcf
bitmap
metadata
windows-server-2003
asked on Stack Overflow Sep 4, 2014 by user1

1 Answer

2

The fix to this was to explicitly use the SetQuery for the metadata... For Example:

BitmapMetadata jpgData = new BitmapMetadata("jpg");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/object name", "Test Title");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/keywords", "Test Tag");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/date created", "20090512");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/time created", "115300-0800");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/caption", "Test Comment");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/by-line", "Test Author");
jpgData.SetQuery("/app13/irb/8bimiptc/iptc/copyright notice", "Copyright 2009");

From a comment on this link

This is because the WIC used in windows server 2003 is not the same as a Windows 7/8 one and cannot be updated. and so metadata.Title etc. throw notfoundexception

answered on Stack Overflow Sep 12, 2014 by user1

User contributions licensed under CC BY-SA 3.0