Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Showcase


Channel Catalog


Channel Description:

ClearScript is a library that makes it easy to add scripting to your .NET applications. It currently supports JavaScript (via V8 and JScript) and VBScript.

older | 1 | .... | 85 | 86 | (Page 87) | 88 | 89 | .... | 115 | newer

    0 0

    I am using JScript engine. I am exposing IE's HTMLWindow2 object to the engine as a global object.

    I suppose my best option would be to implement IDynamicMetaObjectProvider.

    0 0

    Interesting. Is JavaScript code able to access the object's predefined members (e.g., alert())?

    0 0

    Yes, accessing members works fine.

    0 0

    I ended up modifying ClearScript source to solve this problem.

    I modified HostItem
    private bool BindSpecialTarget<T>(out T specialTarget) where T : class
    and included the following code at the beginning of the method:
                if (typeof(T) == typeof(IDynamic))
                {
                    if (target.Type.IsCOMObject)
                    {
                        T dyn = this.engine.MarshalToHost(target.Target, false) as T;
                        if (dyn != null)
                        {
                            specialTarget = dyn;
                            return true;
                        }
                    }
                }

    0 0

    I have tried the above code with JScriptEngine, it has the same issues with singles. What are the main differences between the V8ScriptEngine and JScriptEngine? How should I make the choice between the two?

    0 0

    There is a node.js package called node-inspector to debug node applications.

    https://www.npmjs.com/package/node-inspector

    I tried using it to debug my V8 scripts on ClearScript but could not succeed.

    I start node-inspector using the following command:

    node-inspector -d 9222

    I initialize my V8 engine with the following VB code:

    Dim engine As V8ScriptEngine = New V8ScriptEngine("global", V8ScriptEngineFlags.EnableDebugging, 9222)

    I have "debugger;" statement in my Javascript source code.

    However when I execute the script it does not break at "debugger" statements.

    Can you please test this application for debugging ClearScript?

    0 0

    Great to hear that you found a solution. Thanks!

    0 0

    Hi James2015Li,

    Those classes provide access to two very different JavaScript engines.

    JScript is the engine used by Internet Explorer 8 and earlier. It's relatively slow and doesn't support newer JavaScript features. It also has thread affinity, meaning that each instance can only be used on the thread that created it. On the positive side, it's lightweight, it supports debugging in Visual Studio, and it's easy to deploy.

    V8 is Google's JavaScript engine. It's extremely fast, it doesn't suffer from thread affinity, and it supports most of the latest JavaScript standards. The downside is that it's memory-intensive, it doesn't support debugging in Visual Studio, and it requires the deployment of several native assemblies with your application.

    Good luck!

    0 0

    Thank you very much for the clarification.

    0 0

    After long hours of googling and testing I did succeed debugging ClearScript code using node-inspector.

    First of all, the latest version (0.12.3) has many extensions for debugging node.js scripts so I used an older version (0.5.0) which has less liability to node.js.

    This is advised by the author of node-inspector in the following stackoverflow thread:

    http://stackoverflow.com/questions/22153131/debug-v8-with-node-inspector

    I used the following command to install v0.5.0.
    npm install node-inspector@0.5.0
    You must have node.js (https://nodejs.org/en/) installed on your computer to run this command. Execute it in Node.js command prompt.

    It is installed in folder "%USERPROFILE%\node_modules" by default.

    I added one line of code to %USERPROFILE%\node_modules\node-inspector\lib\PageAgent.js:

    getResourceTree: function(params, done) {
    return; //return empty tree
    ...

    This completes the installation.

    Here is the guide to debug a javascript file executed by ClearScript:

    Open a command prompt and execute the following command:

    %USERPROFILE%\node_modules\.bin\node-inspector.cmd

    You should see the following lines if node-inspector is running successfully.

    Node Inspector v0.5.0
    info - socket.io started
    Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.

    Initialize your V8 engine as in the following code line (VB):

    Dim engine As New V8ScriptEngine("global", V8ScriptEngineFlags.EnableDebugging, 9222)

    Put a breakpoint right after this line in your code and run your application to reach this breakpoint.

    Make sure you have "debugger;" statement in the first line of your JavaScript code.

    Open a Chrome browser and navigate to the following address:

    http://127.0.0.1:8080/debug?port=9222

    Press "Continue Debugging" button in VÄ°sual Studio toolbar.

    Now you should see your script code stopped at the first "debugger;" line in Chrome browser.

    You can continue debugging from here.

    Write in this thread if you have any questions.

    0 0

    Hello ahmetuzun,

    Based on a brief investigation, it looks like node-inspector expects to find certain node.js variables in the script environment. Here's one of the first messages ClearScript receives:
    {"seq":12,"type":"request","command":"evaluate","arguments":{"expression":"JSON.stringify((function () {\n    return {\n      pid: process.pid,\n      cwd: process.cwd(),\n      filename: process.mainModule ? process.mainModule.filename : process.argv[1],\n      nodeVersion: process.version\n    };\n  })()).match(/.{1,80}/g).slice()","global":true,"maxStringLength":-1}}
    And here's V8's response:
    {"seq":3,"request_seq":12,"type":"response","command"
    :"evaluate","success":false,"message":"ReferenceError: process is not defined","
    running":false}
    This appears to confuse node-inspector, as ClearScript receives no further messages. By the way, the tested and recommended V8 debugger for ClearScript is Eclipse with Google Chrome Developer Tools. More information is available in the ReadMe.

    Update: Ah, it looks like you've already found a solution. Thank you very much for posting it!

    Cheers!

    0 0

    Here is the video of the node-inspector debugger embedded in a C# application.

    The application uses the following libraries:

    CefSharp to embed Chrome browser in the application (https://github.com/cefsharp/CefSharp/tree/CefSharp1)

    ClearScript to execute JavaScript code.

    node-inspector (node.js application) + embedded Chrome browser to debug executed code.

    https://youtu.be/rGgfJxEWGds

    0 0

    A JavaScript numeric argument, if it can be converted to an integer without data loss, should match `System.[S]Byte` and `System.[U]Int16` parameters if the narrowing conversion doesn't result in overflow.

    0 0

    A numeric argument, if it can be converted to an integer without data loss, should match `System.[S]Byte` and `System.[U]Int16` parameters if the narrowing conversion doesn't result in overflow.

    0 0

    A numeric argument, if it can be converted to an integer without data loss, should match `System.[S]Byte` and `System.[U]Int16` parameters implicitly if the narrowing conversion doesn't result in overflow.

    0 0

    A numeric argument, if it can be converted to an integer without data loss, should match `System.[S]Byte` and `System.[U]Int16` parameters implicitly if the narrowing conversion doesn't result in overflow.

    0 0

    We're tracking this issue here; it'll be fixed in the next point release, along with the issue affecting field and property assignment. Thanks again!

    0 0

    We're tracking this issue here; it'll be fixed in the next point release. Thanks again!

    0 0

    Exposed COM objects that implement `IDispatchEx` should provide full dynamic access (a-la `IPropertyBag`).

    0 0

    I have previously used the MSScriptControl COM object and have switched to ClearScript. The problem I am seeing, currently, is that whatever implementation ClearScript uses doesn't honor the On Error Resume Next and simply crashes out, throwing an error.

    Is there a way to have ClearScript honor this error handling or something I can do to prevent it from crashing?

older | 1 | .... | 85 | 86 | (Page 87) | 88 | 89 | .... | 115 | newer