Welcome Guest Search | Active Topics | Sign In | Register

Not receiving arguments using eoapi.extInvoke method after upgrade Options
myWorkspace
Posted: Monday, September 20, 2021 10:34:09 AM
Rank: Member
Groups: Member

Joined: 1/6/2016
Posts: 17
Hi,

I am working on upgrading EO.WebBrowser in our .NET project from 19.1.25 to 21.1.67.
We are triggering a bunch of functions in EO like below :

private const string JavascriptInitCode = @"
window['external'] = {
Test: function() {
eoapi.extInvoke('Test', arguments);
}
};
";

this.webBrowserControl.WebControl.WebView.JSInitCode = JavascriptInitCode;
this.webBrowserControl.WebControl.WebView.JSExtInvoke += this.OnJsExtInvoke;

private void OnJsExtInvoke(object sender, JSExtInvokeArgs e)
{
switch (e.FunctionName)
{
case "Test":
e.ReturnValue = this.Test(e.Arguments[0]);
break;
}
}
But having trouble in fetching arguments using eoapi.extInvoke function.
In older version we were getting the context with which the function Test was called with but with newer version we are getting null.

Tried using "RegisterJSExtensionFunction" function as well but getting "eoWebBrowser is not defined" error with this one.
Any advice will be helpful. We are currently using .NET 4.6 framework and windows 10.

Thanks,
eo_support
Posted: Monday, September 20, 2021 11:32:53 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

Your code looks fine. Please update to the latest build and see if it works for you. Also please do not use window['external'] as this variable is being used by WebView.ObjectForScripting property. Additionally, please check the value that you are trying to pass through arguments --- only array of simple values can be passed through arguments. You should not try to pass complex JavaScript object through arguments. This is an important change in the current build vs older build as older build allows you to pass complex objects where as the newer builds no longer allows this (as it causes other problems).

If you continue to have problem, please try to create a test project demonstrating the problem and send the test project to us:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!
myWorkspace
Posted: Tuesday, October 5, 2021 8:14:24 AM
Rank: Member
Groups: Member

Joined: 1/6/2016
Posts: 17
Thanks EO. It seems like issue with passing complex objects. Any specific reason we don't allow passing complex objects in v21 and if there is a possibility in newer builds for it to come back? Also, does passing complex objects through arguments is supported in v20?
eo_support
Posted: Wednesday, October 6, 2021 4:49:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

Passing complex object from JavaScript to .NET will not be supported in the future. The reason is because allowing this would cause JavaScript re-entering issue. See this post for a more detailed explanation of a similar issue:

https://www.essentialobjects.com/forum/postst11933_Return-Result-From-QueueScriptCall-Inside-RegisterJSExtensionFunction.aspx#50407

The root problem of the above issue is GetPlugin (which calls into C# side) could trigger additional JavaScript code that would trigger a re-entering of the JavaScript engine, which should not be allowed as allowing so could cause value "i" to change in the example.

When passing complex object from JavaScript to C# side, the complex object itself is useless unless you have additional code to access member/properties of that object. This additional code would trigger re-entering of the JavaScript engine thus it is not allowed.

Hope this makes sense to you.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.