MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2

Home Page:https://aka.ms/webview2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Problem/Bug]: Added hostObject’s method doesn't support overload?

sq800 opened this issue · comments

commented

What happened?

A host object I added has two methods with the same name, and their parameters are different.

    public uint GetBaseAddress(uint cpuIndex, string memoryName)
    {
        return cpuService.GetBaseAddress(cpuIndex, memoryName);
    }
    public uint GetBaseAddress(string cpuName, string memoryName)
    {
        return cpuService.GetBaseAddress(cpuName, memoryName);
    }

At the frontend,if I call the GetBaseAddress(string cpuName, string memoryName) ,the console throw a Exception:

VM20371:1  Uncaught (in promise) Error: 不支持此接口 (0x80004002)
    at <anonymous>:1:30201

I use Chinese

when I call the GetBaseAddress(uint cpuIndex, string memoryName),it's working.

If I modify GetBaseAddress(string cpuName, string memoryName) to GetBaseAddressByCpuName(string cpuName, string memoryName) ,then call it at frontend,it's working,also.

Is this a bug?

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

124.0.2478.67

SDK Version

1.0.2210.55

Framework

WPF

Operating System

Windows 11

OS Version

No response

Repro steps

Repeat what I describe in What happened,you can reproduce this problem.

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

Unfortunately, this is not a bug. This is a design issue with supporting duck typing languages like JavaScript. The WebView1 WinRT projection had this similar constraint.

From the WinRT documentation

If there is more than one overload that has a matching number of parameters, the first overload that's found in the metadata will be called.