-
net version:4.7.2 I added a specific CLR type reference to the engine like this engine.SetValue("WebSocket", TypeReference.CreateTypeReference(engine, typeof(JSWebSocket)));
// https://github.com/Zaitonn/Serein/blob/c094e5e74d72ef65bcded9970a6b1de562344a0f/Serein/Universal/Plugin/JSEngine.cs#L129-L130
// JSWebSocket is my wrapper for another class
// https://github.com/Zaitonn/Serein/blob/main/Serein/Universal/Plugin/JSWebSocket.cs and I used it in js codes like this var ws = new WebSocket(config.addr); i used it to connect to my ws server and it worked for a while System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.InvalidOperationException: stack is empty
在 Jint.Runtime.ExceptionHelper.ThrowInvalidOperationException(String message, Exception exception)
在 Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArgument, JsValue[] arguments)
--- 内部异常堆栈跟踪的结尾 ---
在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
在 System.Delegate.DynamicInvokeImpl(Object[] args)
在 Serein.Plugin.JSWebSocket.Trigger(Delegate Event, String Name, Object Args) 位置 C:\Users\Administrator\Source\Repos\Serein\Serein\Universal\Plugin\JSWebSocket.cs:行号 65 I cannot call his methods and properties any more 16:39:00 [Serein.Plugin.JSWebSocket.Trigger] MessageReceived事件调用失败 the full logand there is another problem... sometimes it gave me diffierent exception System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.InvalidCastException: 无法将类型为“Jint.Runtime.Environments.DeclarativeEnvironmentRecord”的对象强制转换为类型“Jint.Runtime.Environments.FunctionEnvironmentRecord”。
在 Jint.Engine.FunctionDeclarationInstantiation(FunctionInstance functionInstance, JsValue[] argumentsList)
在 Jint.Native.Function.ScriptFunctionInstance.Call(JsValue thisArgument, JsValue[] arguments)
--- 内部异常堆栈跟踪的结尾 ---
在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
在 System.Delegate.DynamicInvokeImpl(Object[] args)
在 Serein.Plugin.JSFunc.<>c__DisplayClass5_0.<SetTimer>b__0(Object sender, ElapsedEventArgs args) 位置 C:\Users\Administrator\Source\Repos\Serein\Serein\Universal\Plugin\JSFunc.cs:行号 275 is it my problem? :( waiting for your reply❤thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Are you accessing the engine from multiple threads? Engine is not thread-safe. |
Beta Was this translation helpful? Give feedback.
Are you accessing the engine from multiple threads? Engine is not thread-safe.