Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Displays an image in the PictureBox.
Load() |
Displays the image specified by the ImageLocation property of the PictureBox. |
Load(String) |
Sets the ImageLocation to the specified URL and displays the image indicated. |
Displays the image specified by the ImageLocation property of the PictureBox.
public:
void Load();
public void Load();
member this.Load : unit -> unit
Public Sub Load ()
ImageLocation is null
or an empty string.
Starting with .NET 8, the behavior of how a PictureBox
control loads a remote image changed. By default, the System.Net.ServicePointManager.CheckCertificateRevocationList property is set to true
before a remote image is downloaded through WebClient. This setting ensures that servers with certificates have those certificates checked against the certificate authority revocation list (CRL) as part of the validation process.
Warning
As soon as a remote image is loaded, CheckCertificateRevocationList
is changed to true
for the lifetime of the app. You can revert back to false
manually if required, but as soon as another remote image is loaded, CheckCertificateRevocationList
is set to true
.
A previously working remote resource might fail to load when the locally cached CRL is out-of-date and an update can't be retrieved. This can happen when the network the app is running on is restricted and the CRL location isn't on the allowlist.
It's also possible that the delay in checking the CRL negatively affects the app's ability to function.
You can opt out of this behavior by setting the System.Windows.Forms.ServicePointManagerCheckCrl
option for the app, in one of the following ways:
Set the property to false
in the [app].runtimeconfig.json configuration file:
{
"configProperties": {
"System.Windows.Forms.ServicePointManagerCheckCrl": false
}
}
Add a <RuntimeHostConfigurationOption>
item in the project file to disable it:
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Windows.Forms.ServicePointManagerCheckCrl" Value="false" />
</ItemGroup>
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Sets the ImageLocation to the specified URL and displays the image indicated.
public:
void Load(System::String ^ url);
public void Load(string url);
member this.Load : string -> unit
Public Sub Load (url As String)
The path for the image to display in the PictureBox.
url
is null
or an empty string.
url
refers to an image on the Web that cannot be accessed.
url
refers to a file that is not an image.
url
refers to a file that does not exist.
If the url
parameter indicates a local file, the recommended format is a local file path. For example, an image file named myPicture.jpg located at c:\ would be accessed by passing c:\myPicture.jpg
for the url
parameter. A full path, such as http://www.contoso.com/path/images/image.jpg
, or a relative path, such as ./images/image.jpg, can be used. If a relative path is used, it will be considered relative to the working directory. A call to the Load method sets the ImageLocation property to the value of the url
parameter.
Starting with .NET 8, the behavior of how a PictureBox
control loads a remote image changed. By default, the System.Net.ServicePointManager.CheckCertificateRevocationList property is set to true
before a remote image is downloaded through WebClient. This setting ensures that servers with certificates have those certificates checked against the certificate authority revocation list (CRL) as part of the validation process.
Warning
As soon as a remote image is loaded, CheckCertificateRevocationList
is changed to true
for the lifetime of the app. You can revert back to false
manually if required, but as soon as another remote image is loaded, CheckCertificateRevocationList
is set to true
.
A previously working remote resource might fail to load when the locally cached CRL is out-of-date and an update can't be retrieved. This can happen when the network the app is running on is restricted and the CRL location isn't on the allowlist.
It's also possible that the delay in checking the CRL negatively affects the app's ability to function.
You can opt out of this behavior by setting the System.Windows.Forms.ServicePointManagerCheckCrl
option for the app, in one of the following ways:
Set the property to false
in the [app].runtimeconfig.json configuration file:
{
"configProperties": {
"System.Windows.Forms.ServicePointManagerCheckCrl": false
}
}
Add a <RuntimeHostConfigurationOption>
item in the project file to disable it:
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Windows.Forms.ServicePointManagerCheckCrl" Value="false" />
</ItemGroup>
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Please sign in to use this experience.
Sign in