I am trying to call my typescript function in my C# microservice code using below code. But unable to achieve this. Any help is much appreciated.
StreamReader streamReader = new StreamReader("./myinternalprojectfolder/filename.min.js");
string script = streamReader.ReadToEnd();
streamReader.Close();
using (var typescriptEngine = new Jint.Engine())
{
typescriptEngine.Execute(script);
var result = typescriptEngine.Invoke("myfunctionname", argument1, argument2, argument3, argument4);
}
Looks like it is loading the script because I am able to see my typescript related details as shown in below screenshot-
enter image description here
But when while executing the Invoke() function, i get below Error.
Jint.Runtime.JavaScriptException: ‘Can only invoke functions –> JavaScriptErrorWrapperException: Can only invoke functions
Thanks.
I tried the above code.
Chetan Rajakumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.