所以我有這樣的方法來設置最終將被添加到我的形象,一些基本的元數據標籤:服務設置BitmapMetadata.Title在Windows Server 2003 Web版上運行會引發NotSupportedException
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: 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)
作爲localhost在Windows 8.1上運行,這工作正常。只要我將我的服務部署到我的Windows Server 2003網絡版,就會引發顯示的錯誤。發生什麼事?
也許你錯過了一個JPEG編碼器。這通常在名稱空間System.Drawing.Imaging中的System.Drawing.dll中。嘗試做「ImageCodecInfo [] encoderArray = ImageCodecInfo.GetImageEncoders();」並檢查返回的數組中是否至少有一個結果。 – RenniePet 2014-09-04 14:18:58
我已經跑了方法和打印的編解碼器的名稱,並得到: 內置BMP編解碼器, 內置GIF編解碼器, 內置TIFF編解碼器, 內置PNG編解碼器, 我猜我」 m缺少一個jpg編碼器?我如何着手在我的Windows 2003服務器上安裝jpg編碼器? – user1 2014-09-04 14:46:54
是的。不幸的是,我對這個具體情況一無所知。你可以嘗試安裝這個:http://support.microsoft.com/kb/958911(但是如果它導致問題,請不要責怪我:-) – RenniePet 2014-09-04 14:53:48