[Problem/Bug]: WebView2 + WinUI3 + NativeAOT fails with TypeLoadException: Method 'GetVirtualMethodTableInfoForKey' does not have an implementation
mfeingol opened this issue · 1 comments
What happened?
Porting a UWP app to WinUI 3, I'm having trouble using WebView2 with NativeAOT enabled. It works fine without AOT.
I tried a few different versions in Debug configurations with AOT enabled. I observed the following results:
1.0.2950-prerelease
1.0.2903.40
1.0.2849.39
System.TypeLoadException: 'Method 'GetVirtualMethodTableInfoForKey' in type 'Microsoft.Web.WebView2.Core.CoreWebView2' from assembly 'Microsoft.Web.WebView2.Core.Projection, Version=1.0.2903.40, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' does not have an implementation.'
1.0.2792.45
1.0.2651.64
System.NotSupportedException: 'Cannot create an RCW factory for implementation type 'Microsoft.Web.WebView2.Core.CoreWebView2', because it doesn't have a [WinRTImplementationTypeRcwFactory] derived attribute on it. The fallback path for older projections is not trim-safe, and isn't supported in AOT environments. Make sure to reference updated projections.'
I didn't go back further from there.
Importance
Blocking. My app's basic functions are not working due to this issue.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
1.0.2950-prerelease
Framework
WinUI3/WinAppSDK
Operating System
Windows 11
OS Version
26100.2454
Repro steps
Enable PublishAOT with a WinUI 3 app that displays a WebView2.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response