C
C#14mo ago
Danielx64

❔ Needs some help with setting Webview2 option and fixing a known bug

Some background info: I built an app that is currently in production that is pretty much a full screen browser with no address bar or anything like that. It was locked down with most options disabled. It's running well and all but I wanted to extend it a little and add tabs to it (since it was setup to only allow one instance of it running at a time). After seeing this post on stackoverflow (https://stackoverflow.com/a/73087225/1129151), I decided to rebuild it, current source is here (https://github.com/Danielx64/PApps-player/). I'm facing 2 issues: In my current production version, I have the following code:
var options = new CoreWebView2EnvironmentOptions
{
AllowSingleSignOnUsingOSPrimaryAccount = true,
Language = $"{Globals.APP_REQUEST_LANG}"
};

if (!Directory.Exists(Globals.USER_DATA_FOLDER))
{
Directory.CreateDirectory(Globals.USER_DATA_FOLDER);
}
var environment = await CoreWebView2Environment.CreateAsync(null, Globals.USER_DATA_FOLDER, options).ConfigureAwait(true);

await WebView.EnsureCoreWebView2Async(environment).ConfigureAwait(true);
var options = new CoreWebView2EnvironmentOptions
{
AllowSingleSignOnUsingOSPrimaryAccount = true,
Language = $"{Globals.APP_REQUEST_LANG}"
};

if (!Directory.Exists(Globals.USER_DATA_FOLDER))
{
Directory.CreateDirectory(Globals.USER_DATA_FOLDER);
}
var environment = await CoreWebView2Environment.CreateAsync(null, Globals.USER_DATA_FOLDER, options).ConfigureAwait(true);

await WebView.EnsureCoreWebView2Async(environment).ConfigureAwait(true);
Now for some reason I am unable to use that in my current project as it throws CS1503 Argument 1: cannot convert from 'System.Runtime.CompilerServices.ConfiguredTaskAwaitable<Microsoft.Web.WebView2.Core.CoreWebView2Environment>' to 'Microsoft.Web.WebView2.Core.CoreWebView2Environment' (even after editing a few lines to use wv instead and removing await) Right now I am able to get something up and running with
WebView2 wv = new WebView2() { CreationProperties = new CoreWebView2CreationProperties() { UserDataFolder = userDataFolder } };
WebView2 wv = new WebView2() { CreationProperties = new CoreWebView2CreationProperties() { UserDataFolder = userDataFolder } };
But I also need to set CoreWebView2EnvironmentOptions (AllowSingleSignOnUsingOSPrimaryAccount = true) and I am not sure how I can go about this.
Stack Overflow
How to create Tabs using WebView2 in WPF?
I am using WebView2 in WPF and I am trying to simulate creating Tabs. As a first step I am currently trying to simply create a new Tab. My idea for this is to add multiple WebView2 as children of a...
2 Replies
Danielx64
Danielx6414mo ago
Since message is too long, contuning here: My second issue is that when I close the app, for some reasons tabs are not clearing up it's data. This is known issue/bug in the stackoverflow post. Could someone kindly help me debug it? My testing show that it on and off when it clears out data for each tab. Pressing the x on each tab clears the data as it should. Maybe I got some regression or race condition? The source code for the original app (minus company name etc) is here (https://github.com/Danielx64/KioskBrowser-1) Cheers
GitHub
GitHub - Danielx64/KioskBrowser-1: Shows a web page in kiosk mode b...
Shows a web page in kiosk mode by a given url as parameter. Uses WebView2 (Edge Chromium) as an engine. - GitHub - Danielx64/KioskBrowser-1: Shows a web page in kiosk mode by a given url as paramet...
Accord
Accord14mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.