Skip to content

Avoid using LoadAsync() method of PictureBox control  #242

@KlausLoeffelmann

Description

@KlausLoeffelmann

Steps to reproduce:

  1. Create a new WinForms Core App.
  2. Add the following Code to the Form's constructor.
public Form1()
        {
            InitializeComponent();
            System.Windows.Forms.PictureBox pb = new PictureBox();
            pb.ImageLocation = @"\\winformssrvvm01\BAQAFiles\v-mikou\OGF Doc\picture\myLargeImage1.bmp";
            pb.LoadAsync();
        }
  1. Run the app.

Expected Result: LoadAsync should be executed. (NOTE: Although LoadAsync implies this, the method does not return Task but void, so the usage here is correct with regards to async/await.)

Actual Result: An exception pops up, please see following screenshot and exception log.

image

Exception log:

System.PlatformNotSupportedException
  HResult=0x80131539
  Message=Operation is not supported on this platform.
  Source=System.Private.CoreLib
  StackTrace:
   at System.Threading.WaitCallback.BeginInvoke(Object state, AsyncCallback callback, Object object)
   at System.Windows.Forms.PictureBox.LoadAsync()
   at XpictureIssue.Form1..ctor() in C:\Users\v-zheshi\source\winforms\XpictureIssue\Form1.cs:line 20
   at XpictureIssue.Program.Main() in C:\Users\v-zheshi\source\winforms\XpictureIssue\Program.cs:line 19

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 bugProduct bug (most likely)tenet-compatibilityIncompatibility with previous versions or with WinForms for .NET Framework

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions