Skip to content

[Problem/Bug]: When I call a method of a host object that returns a simple dictionary<string,string>, the returned value is always null #5217

Open
@erovas

Description

@erovas

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions