Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WinForms - WebView2 App Crash when targeting .NET5 ARM64 due to System.Windows.Rect #235

Closed
snickler opened this issue Jun 2, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@snickler
Copy link

snickler commented Jun 2, 2020

Application: WindowsFormsApp2.exe
CoreCLR Version: 5.0.20.27907
.NET Version: 5.0.0-preview.6.20279.7
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeLoadException: Could not load type 'System.Windows.Rect' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at Microsoft.Web.WebView2.WinForms.WebView2.InitCoreWebView2Async(CoreWebView2Environment environment)
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at Microsoft.Web.WebView2.WinForms.WebView2.InitCoreWebView2Async(CoreWebView2Environment environment)
   at Microsoft.Web.WebView2.WinForms.WebView2.EnsureCoreWebView2Async(CoreWebView2Environment environment)
   at Microsoft.Web.WebView2.WinForms.WebView2.set_Source(Uri value)
   at WindowsFormsApp2.Form1.InitializeComponent() in C:\Users\jerem\Downloads\WindowsFormsApp2\WindowsFormsApp2\Form1.Designer.cs:line 49
   at WindowsFormsApp2.Form1..ctor() in C:\Users\jerem\Downloads\WindowsFormsApp2\WindowsFormsApp2\Form1.cs:line 19
   at WindowsFormsApp2.Program.Main() in C:\Users\jerem\Downloads\WindowsFormsApp2\WindowsFormsApp2\Program.cs:line 20

When instantiating a new instance of Microsoft.Web.WebView2.WinFoms.WebView2 in a WinForms project on ARM64, setting the Size or Source properties will result in a crash due to the usage of System.Windows.Rect. Digging into the decompilation of the WinForms WebView2 DLL, the culprit is the CoreWebView2Controller.Bounds property. As WPF support support isn't ready for ARM64 in the .NET 5, it seems that relying on a WPF type for use in a WinForms project presents an issue.

Is there any way that the Bounds property can be abstracted from explicitly being tied to Rect?

Thanks!

@pagoe-msft pagoe-msft added bug Something isn't working .NET labels Jun 9, 2020
@pagoe-msft
Copy link

@snickler thanks for raising this issue, I've filed a bug in our backlog.

@RussKie
Copy link

RussKie commented Jul 29, 2020

Windows Forms stack shouldn't use WPF primitives, instead use primitives provided by System.Drawing, e.g. https://docs.microsoft.com/en-us/dotnet/api/system.drawing.rectangle?view=netcore-3.1

@oggy22
Copy link
Member

oggy22 commented Jul 29, 2020

@RussKie that is correct. This is actually our wrapper DLL used both by wpf and winforms. We will switch to

@oggy22
Copy link
Member

oggy22 commented Jul 29, 2020

.... System.Drawing

@champnic
Copy link
Member

champnic commented Aug 5, 2020

This has been resolved and should be available in our next SDK release :)

@champnic champnic added this to the SDK 0.9.628-prerelease milestone Sep 10, 2020
@champnic
Copy link
Member

The fix is now available in the latest prerelease package, 0.9.628-prerelease. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants