PlatformNotSupported Exception thrown by Delegate.BeginInvoke() method
- .NET Core Version: (Version: 3.0.100-preview-009812)
- Have you experienced this same bug with .NET Framework?: No
Problem description:
The call of the Delegate.BeginInvoke method fires the System.PlatformNotSupportedException:
Operation is not supported on this platform.
It looks like a compatibility bug.
Minimal repro:
- Create a new WinForms Core App.
- Add the following Code to the Form's code-behind:
protected override void OnShown(EventArgs e) {
base.OnShown(e);
Action action = new Action(() => {
/* do nothing */
});
action.BeginInvoke(null, this); // PlatformNotSupportedException thrown here
}
Actual Result: The PlatformNotSupported exception thrown.
Expected behavior: The action should be executed without exception.
P.S.
This issue is also cause the #142 issue with PictureBox.LoadAsync method due to following call:
new WaitCallback(this.BeginGetResponseDelegate).BeginInvoke(state, null, null);
@OliaG as mentioned in issue #242 and according to https://github.com/dotnet/corefx/issues/5940#issuecomment-182107557 this is intentional and not a bug. It certainly isn't a bug in WinForms.
We're talking about Delegate.BeginInvoke not about Control.BeginInvoke - the former is part of the framework and not part of WinForms, so this issue is in the wrong place. As linked .NET Core already decided that Delegate.BeginInvoke is intentionally not supported.
@weltkante Whoops, I misread. Deleted my irrelevant comment.
Per @weltkante comment and associated link, I'll close this issue. If you are referring to the Delegate.BeginInvoke is not supported and supposed to throw the exception you found.
So how are you supposed to work with Nuget packages using this internally?
@devedse you may want to ask that over at corefx repo, as said above Control.BeginInvoke from WinForms works just fine, the issue was with Delegate.BeginInvoke which is not part of this repository so you are probably asking the wrong people here.
As far as your question is concerned though, according to the linked discussion, the nuget packes have to be fixed to not use this method if they want to be .NET Core compatible.