MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: WebView2 + WinUI3 + NativeAOT fails with TypeLoadException: Method 'GetVirtualMethodTableInfoForKey' does not have an implementation
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
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
AB#61366797
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named in the report. Start by reproducing the issue with a WinUI 3 app that displays WebView2 and PublishAOT enabled, then inspect the reported TypeLoadException and version-specific behavior. Done means the app can use WebView2 under NativeAOT without the reported load or RCW-factory failures.
Written by the indexing model from the issue text.
Assessment
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100