WebView2 does not support passing in a CoreWebView2Environment
Description The WinUI 3 WebView2 control does not support passing a CoreWebView2Environment object to WebView2.EnsureCoreWebView2Async(), unlike the WPF and Windows Forms controls. In my case, it means I can't use the AllowSingleSignOnUsingOSPrimaryAccount property.
Steps to reproduce the bug
var environment = await CoreWebView2Environment.CreateAsync(null, null, new CoreWebView2EnvironmentOptions
{
AllowSingleSignOnUsingOSPrimaryAccount = true
});
await webView2.EnsureCoreWebView2Async(environment); // doesn't compile
Expected behavior I should be able to pass in a CoreWebView2EnvironmentOptions object to the WebView2 control so I can fully configure the underlying CoreWebView2.
Screenshots n/a
Version Info 0.8
NuGet package version:
| Windows 10 version | Saw the problem? |
|---|---|
| Insider Build (xxxxx) | |
| May 2020 Update (19041) | |
| November 2019 Update (18363) | |
| May 2019 Update (18362) | |
| October 2018 Update (17763) |
Additional context
CC @codendone @krschau
Hi,
Tries made on version Microsoft.WindowsAppSDK 1.0.0
Any news regarding await MyWebView.EnsureCoreWebView2Async(); which don't take env params ?
It's frustrating because with unpackaged app if you install your app in Programs Files it can't work. Indeed Webview create a folder automaticly with cache data close to your executable. So to write into programs files you need admins rights therefore app doesn't work
Regards
@jevansaks @MikeHillberg
The WinUI 3 WebView2 control does not support passing a CoreWebView2Environment object
As it should be. You should be using winui2 not winui 3.
Tries made on version Microsoft.WindowsAppSDK 1.0.0
you shouldn't even.
What do Core Application / Core Window issues and proposals have to do with WindowsAppSDK ; Even after statements like this ?
We won't support CoreApplication https://github.com/microsoft/WindowsAppSDK/issues/1889#issuecomment-990221146
Do you realize ( @andrewleader / @btueffers ) these we won't support CoreApplication but at the same time we'll also take your CoreApplication issues wholeheartedly says about WindowsAppSDK ?
(Yup, theres someone still in the power of windiv politics who still just can't let go CoreWindow at this point and by extension, Users are going to see this deviation in the very near future , It's high time you/your engineers convinced your CoreWindow advocates to try out AppWindow at this point otherwise the developer story are also once again going to take a hit.)
We are temporarily working around this in our application by changing permissions on the User Data folder in Program Files as this not working at all is not an option for us. I am posting this knowing that this is a very bad choice.
@akrebsbach Rather than changing permissions on the folder, I'd recommend using a custom user data folder by setting the WEBVIEW2_USER_DATA_FOLDER environment variable in your app. You can read more about this environment variable and others like it here.
Some people have experienced problems doing this in WinAppSDK 1.1 after it worked in 1.0 (see https://github.com/microsoft/microsoft-ui-xaml/issues/7190), but I'm still investigating why some people have this issue.
We're currently working on exposing the Environment or its options in a way that will solve @bschoepke's problem, but it's not quite ready yet.