MicrosoftEdge / MicrosoftEdge/WebView2Feedback
Accessing a function with parameter that is added using AddHostObjectToScript returns "Parameter is incorrect."
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Description
Hello, I'm new to WebView2 and I've been trying to understand how the code-sharing aspect of it works. Recently, I have been trying out the Host object approach and it only works for me when the function has no required parameter.
Version
SDK:
Runtime:
Framework: WinUI
OS: Win10
Repro Steps
I have tried passing a parameter in my Angular app it like this:
var result = window?.chrome?.webview?.hostObjects.sync.myObject.SayHello("John");
and I keep on getting this error:

I have also tried using the following code:
window?.chrome?.webview?.hostObjects.sync.myObject().SayHello("John");
and it gives a different error:

This is what my code behind looks like:


**NOTE: I am using an interface as webView.CoreWebView2.AddHostObjectToScript() throws an NotImplementedError
Screenshots
Additional context
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.
Research direction
Start with the WinUI host-object setup and the Angular calls to window.chrome.webview.hostObjects.sync.myObject.SayHello("John") and the alternate invocation shown in the issue. Reproduce both errors using the reported WebView2 configuration, then establish whether parameterized SayHello calls are expected to work and document the confirmed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, javascript
- Domain
- api, desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100