Quantcast
Channel: ClearScript
Viewing all 2297 articles
Browse latest View live

New Post: Host objects that implement IExpando (IDispatchEx)

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.

New Post: Host objects that implement IExpando (IDispatchEx)

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

New Post: Host objects that implement IExpando (IDispatchEx)

0
0
Yes, accessing members works fine.

New Post: Host objects that implement IExpando (IDispatchEx)

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;
                    }
                }
            }

New Post: How to pass short int from script to C# methods

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?

New Post: Debugging with node-inspector

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?

New Post: Host objects that implement IExpando (IDispatchEx)

0
0
Great to hear that you found a solution. Thanks!

New Post: How to pass short int from script to C# methods

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!

New Post: How to pass short int from script to C# methods

0
0
Thank you very much for the clarification.

New Post: Debugging with node-inspector

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.

New Post: Debugging with node-inspector

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!

New Post: Debugging with node-inspector

Created Issue: [BUG] JavaScript integer arguments don't match System.[S]Byte or System.[U]Int16 parameters [95]

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.

Edited Issue: [BUG] Explicit conversion is always required for System.[S]Byte and System.[U]Int16 parameters [95]

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.

Edited Issue: [BUG] Casting is always required for System.[S]Byte and System.[U]Int16 parameters [95]

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.

Edited Issue: [BUG] Casting is always required for [S]Byte and [U]Int16 parameters [95]

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.

New Post: How to pass short int from script to C# methods

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!

New Post: Host objects that implement IExpando (IDispatchEx)

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

Created Issue: [BUG] Exposed IDispatchEx instances don't support dynamic properties [96]

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

Created Unassigned: On Error Resume Next in VBScript [97]

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?
Viewing all 2297 articles
Browse latest View live




Latest Images