I am having issues with the .NET WebView2 control. I thought I had it fixed but it is not working. I have read numerous posts to no avail.
I have a WPF C# application that runs on a server. Various people log into the server via a web browser and run the app.
Within this app, I open up a WebView2 browser, setting the user data directory to a unique directory for each person.
When I set the user data directory and call EnsureCoreWebView2Async(), I get an error in the exception code "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Below is the code:
public static async void InitializeWebView(WebView2 browser, string path){ Directory.CreateDirectory(path); browser.CreationProperties = new CoreWebView2CreationProperties() { UserDataFolder = path }; try { await browser.EnsureCoreWebView2Async(); } catch( Exception ex) { Log.LogString("Ensure error: " + ex.Message); }}
I have tried various things without success. What am I doing wrong? Any suggestions?