ServicePointManager and WebClient are obselete, but are being used in PictureBox
|
private void LoadImageViaWebClient() |
|
{ |
|
Image img; |
|
Uri uri = CalculateUri(_imageLocation!); |
|
if (uri.IsFile) |
|
{ |
|
_localImageStreamReader = new StreamReader(uri.LocalPath); |
|
img = Image.FromStream(_localImageStreamReader.BaseStream); |
|
} |
|
else |
|
{ |
|
if (LocalAppContextSwitches.ServicePointManagerCheckCrl) |
|
{ |
|
ServicePointManager.CheckCertificateRevocationList = true; |
|
} |
|
|
|
#pragma warning disable SYSLIB0014 // Type or member is obsolete |
|
using WebClient webClient = new(); // lgtm[cs/webrequest-checkcertrevlist-disabled] - Having ServicePointManager.CheckCertificateRevocationList set to true has a slim chance of resulting in failure. We have an opt-out for this rare event. |
|
#pragma warning restore SYSLIB0014 // Type or member is obsolete |
|
_uriImageStream = webClient.OpenRead(uri.ToString()); |
|
img = Image.FromStream(_uriImageStream); |
|
} |
|
|
|
InstallNewImage(img, ImageInstallationType.FromUrl); |
|
} |
We needed to suppress SYSLIB0014 warning in #11540 to unblock depdency flow, but we should update this code to use HttpClient
ServicePointManagerandWebClientare obselete, but are being used inPictureBoxwinforms/src/System.Windows.Forms/src/System/Windows/Forms/Controls/PictureBox/PictureBox.cs
Lines 500 to 524 in 520c319
We needed to suppress
SYSLIB0014warning in #11540 to unblock depdency flow, but we should update this code to useHttpClient