在Windows Server 2003 Web Edition上运行的服务中设置BitmapMetadata.Titl
本文关键字:服务 设置 Titl BitmapMetadata 运行 Server Windows 2003 Web Edition | 更新日期: 2023-09-27 18:20:49
所以我有这个方法来设置一些基本的元数据标签,这些标签最终会添加到我的图像中:
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
}
}
我不断得到错误:
System.NotSupportedException:没有适用于已找到完整的此操作。--->System.Runtime.InteropServices.COMException:HRESULT中的异常:0x88982F50''---内部异常堆栈跟踪结束---''在System.Windows.Media.Imageing.BitmapMetadata.SetQuery(字符串查询,对象值)''atSystem.Windows.Media.Imageing.BitmapMetadata.set_Title(字符串值)
在Windows 8.1上以localhost身份运行,效果良好。一旦我将服务部署到WindowsServer2003WebEdition,它就会抛出显示的错误。发生了什么?
对此的修复是显式使用元数据的SetQuery。。。例如:
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");
来自这个链接的评论
这是因为windows server 2003中使用的WIC与windows 7/8不同,无法更新。元数据也是如此。标题等抛出未找到异常