使用BitmapImage.BeginInit()时未捕获ArgumentException

|| 为什么当由于image.jpg具有无效的元数据头而发生ArgumentException时,第一个示例没有捕获异常,而第二个示例没有捕获异常? 范例1:
try
{
Uri myUri = new Uri(\"http://example.com/image.jpg\", UriKind.RelativeOrAbsolute);
JpegBitmapDecoder decoder2 = new JpegBitmapDecoder(myUri,
                             BitmapCreateOptions.PreservePixelFormat,
                             BitmapCacheOption.Default);
BitmapSource bitmapSource2 = decoder2.Frames[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
范例2:
try
{
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(\"http://example.com/image.jpg\");
src.EndInit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
    
已邀请:
可能要等到要求加载图像为止,例如将其设置为“ 2”控件的源。 如果您添加了它,可能会给您带来例外
src.CacheOption = BitmapCacheOption.OnLoad;
您的声明。     

要回复问题请先登录注册