MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Value does not fall within the expected range
@champnic is already working on this.
Since Jan 17, 2023.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
at Microsoft.Web.WebView2.Core.Raw.ICoreWebView2Controller.MoveFocus(COREWEBVIEW2_MOVE_FOCUS_REASON reason)
at Microsoft.Web.WebView2.Core.CoreWebView2Controller.MoveFocus(CoreWebView2MoveFocusReason reason)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.Interop.HwndKeyboardInputProvider.OnSetFocus(IntPtr hwnd)
at System.Windows.Interop.HwndKeyboardInputProvider.FilterMessage(IntPtr hwnd, WindowMessage message, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
webview2 version:1.0.1370.28
my wpf code:
1、MainWindow
` private async void Window_Loaded(object sender, RoutedEventArgs e)
{
webBrw.CoreWebView2InitializationCompleted += WebBrw_CoreWebView2InitializationCompleted;
if (webBrw.CoreWebView2 == null)
{
var env = await CoreWebView2Environment.CreateAsync();
await webBrw.EnsureCoreWebView2Async(env);
}
}
private async void WebBrw_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
if (e.IsSuccess)
{
webBrw.CoreWebView2.AddHostObjectToScript("Common", new CommonBridge(webBrw));
webBrw.CoreWebView2.Navigate("http://localhost:8011/");
}
}
2、Window1
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
webBrw.CoreWebView2InitializationCompleted += WebBrw_CoreWebView2InitializationCompleted;
if (webBrw.CoreWebView2 == null)
{
var env = await CoreWebView2Environment.CreateAsync();
await webBrw.EnsureCoreWebView2Async(env); // error occurred
}
}
private async void WebBrw_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e)
{
if (e.IsSuccess)
{
webBrw.CoreWebView2.Navigate(WebUrl);
}
}
3、CommonBridge
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class CommonBridge
{
private Microsoft.Web.WebView2.Wpf.WebView2 webView = null;
public CommonBridge()
{
}
public CommonBridge(Microsoft.Web.WebView2.Wpf.WebView2 view)
{
webView = view;
}
public void OpenWindow(string url)
{
Window1 wd = new Window1(url);
wd.ShowDialog();
}
}
4、 js
var ret= await window.chrome.webview.hostObjects.Common.OpenWindow('https://github.com');
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.