AddBrowserExtensionAsync Error
bearsInformation opened this issue · 6 comments
bearsInformation commented
What happened?
An error occurs when using AddBrowserExtensionAsync.
error
System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
Stack trace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) in System.Reflection\RuntimeMethodInfo.cs:line 625
at System.Delegate.DynamicInvokeImpl(Object[] args) in System\Delegate.cs:line 158
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) in System.Windows.Forms\Control.cs:line 10635
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) in System.Windows.Forms\Control.cs:line 10597
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading\ExecutionContext.cs:line 518
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading\ExecutionContext.cs:line 489
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) in System.Threading\ExecutionContext.cs:line 482
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) in System.Windows.Forms\Control.cs:line 10580
at System.Windows.Forms.Control.InvokeMarshaledCallbacks() in System.Windows.Forms\Control.cs:line 10657
at System.Windows.Forms.Control.WndProc(Message& m) in System.Windows.Forms\Control.cs:line 15870
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) in System.Windows.Forms\Control.cs:line 135
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) in System.Windows.Forms\Control.cs:line 163
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) in System.Windows.Forms\NativeWindow.cs:line 743
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) in System.Windows.Forms\Application.cs:line 304
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) in System.Windows.Forms\Application.cs:line 1235
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) in System.Windows.Forms\Application.cs:line 1151
at System.Windows.Forms.Application.Run(Form mainForm) in System.Windows.Forms\Application.cs:line 3091
This exception was first thrown by this call stack
Microsoft.Web.WebView2.Core.CoreWebView2Profile.AddBrowserExtensionAsync(string) (CoreWebView2Profile.cs in)
WebView2_TEST_C_.Form1.WebView2_CoreWebView2InitializationCompleted(object, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs) (Form1.cs in)
System.Runtime.CompilerServices.AsyncMethodBuilderCore.ThrowAsync.AnonymousMethod__6_0(object) (AsyncMethodBuilderCore.cs in) was thrown at
Inner Exception 1:
COMException: Class not registered
Class not registered
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
131.0.2903.70
SDK Version
1.0.2903.40
Framework
Winforms
Operating System
Windows 11
OS Version
23H2
Repro steps
code
using Microsoft.Web.WebView2.Core;
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WebView2_TEST_C_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private async Task InitializeAsync()
{
WebView2.CoreWebView2InitializationCompleted += WebView2_CoreWebView2InitializationCompleted;
var options = new CoreWebView2EnvironmentOptions();
options.AreBrowserExtensionsEnabled = true;
CoreWebView2Environment environment = await CoreWebView2Environment.CreateAsync(null, null, options);
await WebView2.EnsureCoreWebView2Async(null);
}
private async void Form1_Load(object sender, EventArgs e)
{
await InitializeAsync();
}
private async void WebView2_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
// Operation confirmed on edge
var path = @"<%userprofile%>AppData\Local\Microsoft\Edge\User Data\Default\Extensions\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\1.0.0.0_0";
var extension = await WebView2.CoreWebView2.Profile.AddBrowserExtensionAsync(path);
}
}
}
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Don't know
Last working version (if regression)
No response