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

[Problem/Bug]: WebView2 Nuget packages don't support NativeAOT w/ WinAppSDK 1.6+ #4800

Closed
zhuman opened this issue Sep 10, 2024 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@zhuman
Copy link

zhuman commented Sep 10, 2024

What happened?

WinAppSDK 1.6+ and CsWinRT 2.1.1 have released in August and added major support for NativeAOT with .NET 8. This means that you can build WinAppSDK apps or apps using WinRT APIs and use the <PublishAot>true</PublishAot> property in your project to make the build process trim and compile your entire project down into one native DLL/EXE.

How to fix it?

The Microsoft.Web.WebView2 Nuget package needs to be updated to build with CsWinRT 2.1.1 in order to get this benefit as well. I think literally just update your CsWinRT dependency and rebuild to get updated projections.

What is broken?

Until this is fixed, you can build a WinAppSDK NativeAOT app that works fine until the WebView2 classes are called. They will fail with the message:

Cannot create an RCW factory for implementation type 'Windows.Foundation.IAsyncOperation`1[Microsoft.Web.WebView2.Core.CoreWebView2Environment]'.

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.2783-prerelease

Framework

WinUI3/WinAppSDK

Operating System

Windows 11

OS Version

22635.4145

Repro steps

  1. Create a WinAppSDK 1.6 app with .NET 8 and include a WebView2 component.
  2. Add <PublishAot>true</PublishAot> to your project file.
  3. Publish the app (triggering the full compilation to native code) and try to run it.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@zhuman zhuman added the bug Something isn't working label Sep 10, 2024
@zhuman
Copy link
Author

zhuman commented Sep 10, 2024

Note internally this is tracked by bug 53191953.

This will work once a Nuget version >= 1.0.2798 drops.

@Gaoyifei1011
Copy link

What happened?

WinAppSDK 1.6+ and CsWinRT 2.1.1 have released in August and added major support for NativeAOT with .NET 8. This means that you can build WinAppSDK apps or apps using WinRT APIs and use the <PublishAot>true</PublishAot> property in your project to make the build process trim and compile your entire project down into one native DLL/EXE.

How to fix it?

The Microsoft.Web.WebView2 Nuget package needs to be updated to build with CsWinRT 2.1.1 in order to get this benefit as well. I think literally just update your CsWinRT dependency and rebuild to get updated projections.

What is broken?

Until this is fixed, you can build a WinAppSDK NativeAOT app that works fine until the WebView2 classes are called. They will fail with the message:

Cannot create an RCW factory for implementation type 'Windows.Foundation.IAsyncOperation`1[Microsoft.Web.WebView2.Core.CoreWebView2Environment]'.

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.2783-prerelease

Framework

WinUI3/WinAppSDK

Operating System

Windows 11

OS Version

22635.4145

Repro steps

  1. Create a WinAppSDK 1.6 app with .NET 8 and include a WebView2 component.
  2. Add <PublishAot>true</PublishAot> to your project file.
  3. Publish the app (triggering the full compilation to native code) and try to run it.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

#4783

@oggy22
Copy link
Member

oggy22 commented Sep 15, 2024

This seems to be a duplicate of #4783 which has been fixed.

@oggy22 oggy22 closed this as completed Sep 15, 2024
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

3 participants