question

VinodhkumarArumugam-5755 avatar image
0 Votes"
VinodhkumarArumugam-5755 asked VinodhkumarArumugam-5755 commented

Not able to send arguments from javascript to reflection object methods.

Hi, I am working on a project to embed edge chromium in c# windows application. In this application I am trying to add reflection objejct for scripting but not able to receive method arguments from javascript.

public object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters)
{
}
}
-I created object and created delegate methods for the above clases and added object like
_webBrowser.CoreWebView2.AddHostObjectToScript("ChromeBrowser", dynamicPluginObject);
- I am trying to call method from javascript like chrome.webview.hostObjects.sync.ChromeBrowser['GetCustomerID'] for this I am able to getting into Invokemember method and able execute.
- Trying to call method with parameter like
chrome.webview.hostObjects.sync.ChromeBrowser.['SetCustomerID'] .apply(null,argumentsList); I am getting null for args in the Invokemember.


Can anyone help me on this. How to add reflection object to edge chromium for scripting?

Thanks
Vinodh Kumar


ms-edge
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @VinodhkumarArumugam-5755 , I tried to use part of the code you provided, and got this result, and the reason for this error was to add the wrong dot symbol here: ChromeBrowser.['SetCustomerID']. And I'm not sure how your test object (dynamicPluginObject) is defined, or there may be other issues. If possible, please provide a sample code snippet that can reproduce the problem. This will help solve the problem, thank you for your understanding.

0 Votes 0 ·

Hi @XuDongPeng-MSFT, Thanks for your reply.

  • I uploaded my source here https://github.com/vinoarumugam/edgechromimum.

  • I added my html file CheckExternal.html also with source. Please update path in the edgeChromeBrowser.cs code for _webBrowser.Source = new Uri("file:///C:/Microsoft-Git/edgeChromium/CheckExternal.html");

  • I am trying to send arguments for the method SetCustomerID but failing. Can you help me on this?


Thanks
Vinodh Kumar



0 Votes 0 ·

0 Answers