//the Script Object
[ComVisible(true)]
[Guid("21A6CC64-8E9A-4659-85AA-32A07B2BDA0B")]
public class TestObject
{
public string FirstMessage {get;set;}
public string SencondMessage{get;set;}
public int GetStringLen(string input)
{
return input.Length;
}
}
//program.cs
class Program
{
private static TestObject _TestObj;
static void Main(string[] args)
{
_TestObj = new TestObject();
_TestObj.FirstMessage = "This is a message from Com!";
var window = new WebWindow("My great app", options =>
{ ...
//At the end!
window.AddRemoteObject("testObject", _TestObj);
window.NavigateToLocalFile("wwwroot/index.html");
window.WaitForExit();
}
...
The only question is whether this also works on Mac and Linux. Unfortunately I don't have the possibility to test it. I also don't know if this function is available for Mac and Linux at all? So it would be good if one could do this.
Hi There, WebView2 inteface IWebView2WebView5 supports AddRemoteObject. this can be a ComVisible DotNet-Class. So it would be nice to implement it.
I try it on WebWindow.Windows.cpp and it works:
Dotnet Site:
Client side:
The only question is whether this also works on Mac and Linux. Unfortunately I don't have the possibility to test it. I also don't know if this function is available for Mac and Linux at all? So it would be good if one could do this.
Best regards