MicrosoftEdge / MicrosoftEdge/WebView2Feedback

API calls using DevToolsProtocolHelper throw an exception

Open
#1,100 2 comments 0 reactions 1 assignee View on GitHub

@champnic is already working on this.

Since Mar 26, 2021.

feature request tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
Using the newly released Microsoft.Web.WebView2.DevToolsProtocolExtension package to access the DevTools Protocol API results in this exception:
"System.ArgumentException: Value does not fall within the expected range."

Version
SDK: Microsoft.Web.WebView2 1.0.824-prerelease, Microsoft.Web.WebView2.DevToolsProtocolExtension 1.0.824
Runtime: Evergreen, 89.0.774.57
Framework: Windows.Forms, .NET Framework 4.8
OS: Win10

Repro Steps
Based on the steps provided here:
https://docs.microsoft.com/en-us/microsoft-edge/webview2/howto/chromium-devtools-protocol

    async void InitializeAsync()
    {
        await webView.EnsureCoreWebView2Async(null);
        DevToolsProtocolHelper helper = webView.CoreWebView2.GetDevToolsProtocolHelper();

        webView.CoreWebView2.Navigate(@"C:\temp\test.html");

        // Latitude and longitude for Paris, France.
        double latitude = 48.857024082572565;
        double longitude = 2.3161581601457386;
        double accuracy = 1;
        await helper.Emulation.SetGeolocationOverrideAsync(latitude, longitude, accuracy);
        // OK so far

        // Results in exception
        var x = await helper.SystemInfo.GetInfoAsync();
        MessageBox.Show(x.ModelName);
    }

Here are the exception details:

************** Exception Text **************
System.ArgumentException: Value does not fall within the expected range.
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at Microsoft.Web.WebView2.Core.CoreWebView2.d__134.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Web.WebView2.Core.DevToolsProtocolExtension.SystemInfo.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at WindowsFormsApp1.Form1.d__1.MoveNext() in C:\Users\volar\source\repos\WindowsFormsApp1\WindowsFormsApp1\Form1.cs:line 37
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)

Thanks.

AB#32257666

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.