我遇到一个问题,就是无法通过URL下载图像到BitmapImage中。
在一些工作站上这个功能无法使用,我也不知道为什么...
例如,在我的工作站上,这个功能能够正常工作。操作系统和网络环境都一样。
我有一段代码,从Web服务器加载一些图像,并在ListView中显示它们。
以下是处理下载的代码部分:
Application.Current.Dispatcher.Invoke((Action)(delegate
{
try
{
DTOBild dtoBild = new DTOBild();
BitmapImage small_image_bmp = new BitmapImage(new Uri( "http://our-own-server/images/99999999/" + bild));
dtoBild.bitmap = small_image_bmp;
this.listeBilder.Add(dtoBild);
}
catch (Exception ex)
{
log.schreibeFehler("Error at loading image. Stack is following ...");
log.schreibeFehler(ex.Message);
log.schreibeFehler(ex.StackTrace);
}
}));
代码在这行崩溃:
BitmapImage small_image_bmp = new BitmapImage(new Uri( "http://our-own-server/images/99999999/" + bild));
这是一个异常:
HRESULT 异常: 0x80072EE4 在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) 中引发异常 在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) 中引发异常 在 MS.Win32.WinInet.get_InternetCacheFolder() 中调用 在 System.Windows.Media.Imaging.BitmapDownload.BeginDownload(BitmapDecoder decoder, Uri uri, RequestCachePolicy uriCachePolicy, Stream stream) 中调用 在 System.Windows.Media.Imaging.LateBoundBitmapDecoder..ctor(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy requestCachePolicy) 中调用 在 System.Windows.Media.Imaging.BitmapDecoder.CreateFromUriOrStream(Uri baseUri, Uri uri, Stream stream, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption, RequestCachePolicy uriCachePolicy, Boolean insertInDecoderCache) 中调用 在 System.Windows.Media.Imaging.BitmapImage.FinalizeCreation() 中调用 在 System.Windows.Media.Imaging.BitmapImage.EndInit() 中调用
有人能帮我吗?