Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AddHostObject To Engine but call cannot working #1

Open
stone89son opened this issue Jul 9, 2020 · 3 comments
Open

Add AddHostObject To Engine but call cannot working #1

stone89son opened this issue Jul 9, 2020 · 3 comments

Comments

@stone89son
Copy link

Thank for good javascript engine.
I want to print result from JS code to RichTextBox. so I using AddHostObject.
My Code add to C# My Application:
shipEngine.Engine.AddHostObject("rtbResult", rtbResult);
My code Add to JS code:
rtbResult.Text="aaaaa";
But. When i run application give to error:
System.InvalidOperationException: 'Module 'repl' not found.'

If I use ClearScript is run OK.

@edongashi
Copy link
Owner

Hello @stone89son. You may need to transform templates Build > Transform All T4 Templates when building the project. Not sure if this will fix your problem. If ClearScript does what you need then you may be better off sticking to that.

This project is very old and in dire need of a refactor. I could clean it up during the weekend.

@stone89son
Copy link
Author

■"This project is very old and in dire need of a refactor. I could clean it up during the weekend."
=>Thank you. I hope support good for AddHostObject... same ClearScript. and design good to support for winform.
=>I try ClearScript . not support import dll,json. inconvenience for my project.

@stone89son stone89son reopened this Jul 9, 2020
@edongashi
Copy link
Owner

edongashi commented Jul 11, 2020

I have looked around the ClearScript project and it has added some nice features.

Considering they are supporting CommonJS and ES6 modules, then other features can be implemented using those.
For example, you could have a json module which loads a file using CLR methods and parses its content using JSON.parse().
For DLLs you could expose a dynamic DLL loader from dotnet side.

But anyhow, we could tweak (and simplify) this library a bit by making it a convenient wrapper around CommonJS modules. I don't see how we could implement ES6 with stuff like JSON or DLLs.

I say we make the following:

  • Dynamically registered module types.
  • Wrapper around the V8ScriptEngine with easy registration of modules.
  • Some convenience modules in an extension library. We wouldn't want to bloat the base library with optional stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants