Closed CzaiStefanB closed 4 years ago
Hello!
This error:
Error: During invocation of the host delegate an error has occurred - "Parameter count mismatch.".
at Global code (Script Document [2]:1:1) -> Sleep();
occurs because you embedded a delegate to JS engine, which can take only one integer parameter:
javaEngine.EmbedHostObject("Sleep", (Action<int>)System.Threading.Thread.Sleep);
You have only two variants for solving this problem:
Sleep
method.JsUsageException
occurs due to the fact that intercepting entire exception, you continue to use JS engine in which error occurred.
I'm expecting the first exception with "parameter count mismatch" when I call Sleep without parameter. From my point of view this is correct behaviour and the JS engine also is still working correctly after that call.
But when I call the Sleep with two parameters I get a different exception with "Runtime is active on another thread." and afterwards the JS engine is not working any longer. The whole program is crashing without any exception or comment (I guess due to problem in native code). Why I don't get the same "parameter count mismatch" exception when using too many parameters? I think the runtime should handle that the same way like when having to less parameters and the JS engine should also not be corrupted after such a call.
I found the cause of error. Tomorrow I will publish a new version.
Thanks for information!
Hello!
This error is fixed in version 3.4.3.
Now the ChakraCore module, like other engines, discards extra parameters before calling the delegate. No exceptions occur during such call.
I have tested the functionality in the new version and it works like expected. I will close the issue.
Thanks for the quick bug fixing!
Hello,
I have a strange behaviour when calling embedded functions with too much parameters.
I think something gets corrupted in background because with the next function call the program is crashing. When calling a function with too less parameters everything is working like expected. You can use the following code to reproduce this behaviour: