WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

[Problem/Bug]: How to properly use AddBrowserExtensionAsync in UWP with WebView2?

Open Vict0r-Chen opened this issue 1 year ago • 4 comments

What happened?

I am trying to use the AddBrowserExtensionAsync method in a UWP application with WebView2, but I am encountering issues. According to the Microsoft documentation, it seems that this method should allow me to add browser extensions to the WebView2 control. However, I am not able to get it working as expected.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime), Prerelease (Edge Canary/Dev/Beta)

Runtime Version

131.0.2903.112

SDK Version

1.0.2903.40

Framework

WinUI2/UWP

Operating System

Windows 10, Windows 11

OS Version

23H2

Repro steps

Steps to Reproduce:

Set up a UWP project with WebView2.

Attempt to use the AddBrowserExtensionAsync method to add a browser extension.

Observe that the extension is not loaded or the method throws an exception.

Expected Behavior: The AddBrowserExtensionAsync method should successfully add the specified browser extension to the WebView2 control.

Actual Behavior: The extension is not loaded, or the method throws an exception (please specify the exception if any).

Additional Information:

WebView2 SDK Version: [Insert version here]

UWP Target Version: [Insert version here]

OS Version: [Insert version here]

Any relevant code snippets or error messages.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

N/A

Vict0r-Chen avatar Jan 10 '25 15:01 Vict0r-Chen

Hi @Vict0r-Chen Can you provide a small snippet on how you are using AddBrowserExtensionAsync method in your application. Please also specify what exception are you getting on using the above method.

chetanpandey1266 avatar Jan 16 '25 20:01 chetanpandey1266

Hi @chetanpandey1266

About the snippet:

var webView2Environment = await CoreWebView2Environment.CreateWithOptionsAsync(string.Empty, string.Empty, new CoreWebView2EnvironmentOptions()
{
    AreBrowserExtensionsEnabled = true,
});
await webView.EnsureCoreWebView2Async();
await webView.CoreWebView2.Profile.AddBrowserExtensionAsync(@"%localappdata%\Microsoft\Edge\User Data\Default\Extensions\olofadcdnkkjdfgjcmjaadnlehnnihnl\6.6.3_0");

The expectation is that after launching my app, I should be able to see the Vue Devtools in the developer tools. However, when executing AddBrowserExtensionAsync, I receive an error: "The request is not supported."

Vict0r-Chen avatar Feb 10 '25 08:02 Vict0r-Chen

@Vict0r-Chen did you able to resolve, im facing same issue?

qayyumabro avatar Mar 02 '25 11:03 qayyumabro

@qayyumabro Nope, I tried to use Vue DevTools before, but now I am using the standalone Vue DevTools app instead😂

Vict0r-Chen avatar Mar 08 '25 03:03 Vict0r-Chen