MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: When I call a method of a host object that returns a simple dictionary<string,string>, the returned value is always null
@prija-microsoft is already working on this.
Since Apr 28, 2025.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
I am using the following project:
https://github.com/rgwood/MinimalWebView
I have updated the SDK to the latest version (it also fails with older versions).
I add a simple hostobject like this:
`
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Prueba
{
public object Hacer(object obj)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("texto", "hola");
dic.Add("numeros", "sdsd");
return dic;
}
}`
And in JS I do:
let valor = window.chrome.webview.hostObjects.sync["Prueba"].Hacer(123)
Expected value: valor = { texto: "hola", numeros: "sdsd" }
I received always: valor = null
Importance
Low. My app is not very affected, or this only affects development.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
No response
SDK Version
No response
Framework
Other
Operating System
Windows 10
OS Version
No response
Repro steps
I am using the following project:
https://github.com/rgwood/MinimalWebView
I have updated the SDK to the latest version (it also fails with older versions).
I add a simple hostobject like this:
`
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Prueba
{
public object Hacer(object obj)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("texto", "hola");
dic.Add("numeros", "sdsd");
return dic;
}
}`
And in JS I do:
let valor = window.chrome.webview.hostObjects.sync["Prueba"].Hacer(123)
Expected value: valor = { texto: "hola", numeros: "sdsd" }
I received always: valor = null
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
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.