WPF Image control binds an error that the Times cannot read from the stream

errors that cannot be read from the stream by the binding Times of the Image control

it is found that there is a problem with the picture. Refer to the detection method of using HttpWebRequest on the Internet, combined with finding that the PropertyItems of the problem picture is empty (not sure whether it can be used as a basis for judgment).

personal example:

// ;
foreach ( info in res.data)
{
    if (string.IsNullOrEmpty(info.hospitalPicture))
    {
        continue;
    }
 
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(info.hospitalPicture);
    WebResponse response = request.GetResponse();
    Image img = Image.FromStream(response.GetResponseStream());
 
    if (img.PropertyItems.Length == 0)
    {
        Logger.Net.Debug($"[]{info.hospitalName}");
        ShowAlert(false, "", $"{info.hospitalName} ");
        info.hospitalPicture = "";
    }
}
 
var buttons = res.data.Select(x => new HospitalButtonInfo()
{
    Name = x.hospitalName,
    HospitalId = x.hospitalId,
    Order = x.hospitalId == FrameworkConst.HospitalId ? 1 : 2,
    IsEnabled = true,
    ImageSource = string.IsNullOrEmpty(x.hospitalPicture) ? ResourceEngine.GetImageResource("_House") : new BitmapImage(new Uri(x.hospitalPicture, UriKind.Absolute))
}).ToList();
 
Data = buttons;

construct
in addition, the error should occur after constructing the BitmapImage, not when the control binds the data, because putting the foreach section after building the buttons will still make an error, which also indicates that there is a delay in constructing the BitmapImage? That is, even if the ImageSource is reassigned later, the previous BitmapImage build will still run.

Wpf
Mar.21,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e445f8-59032.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e445f8-59032.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?