Hi @Vishal2 Bansal ,
Thanks for your question.
In WinUI 3, WebView2 runs browser processes under the current user context, and it requires full access not only to the specified user data folder, but also the ability to create and manage its internal structure. Even if the folder appears writable, certain locations may still block non-admin processes due to Windows security restrictions.
The error 0x8007139F typically indicates that WebView2 failed to initialize its runtime environment, which can happen when the user data folder is not fully accessible or is in an invalid state.
You can refer to some of the solutions and example code below:
- Use a per-user writable location such as LocalApplicationData:
string baseDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string userDataFolder = Path.Combine(baseDataPath, "YourAppName", "UserData", currentUserId); // currentUserId is whatever you use to separate users
Directory.CreateDirectory(userDataFolder);
var env = await CoreWebView2Environment.CreateAsync(
browserExecutableFolder: null,
userDataFolder: userDataFolder,
options: null);
await myWebView.EnsureCoreWebView2Async(env);
- Add error catching so you can see the real message.
try
{
var env = await CoreWebView2Environment.CreateAsync(...);
await myWebView.EnsureCoreWebView2Async(env);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"WebView2 failed: {ex.Message}");
if (ex.InnerException != null)
System.Diagnostics.Debug.WriteLine($"Inner: {ex.InnerException.Message}");
}
- If the folder was created by admin before, run the app once as admin, let it create the folder, then close it. After that, normal users should be able to use it.
- Try removing the custom userDataFolder completely and let WinUI3 use its own safe default location. Only use custom if you really need separate folders per use.
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback