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 | .... | 12 | 13 | (Page 14) | 15 | 16 | .... | 115 | newer

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17

    0 0

    Hi everybody,

    I just noticed a behavior that differs between ClearScript v 5.3.9 and 5.3.10, and it's about limiting memory for a script execution. Consider following faulty script (it emulates a memory leak) being executed inside the 64 bit console application:
    ```
    var sample_arr = [-1, 5, 7, 4, 0, 1, -5]
    function My_Partition(container, first_index, last_index) {
    var x = container[last_index];
    var i = first_index - 1;

    for (var elem = 0; elem < container.length-1; elem++) {
    if (container[elem] <= x) {
    i += 1;
    var temp_1 = container[i];
    container[i] = container[elem];
    container[elem] = temp_1;
    }
    }
    var temp_2 = container[i+1];
    container[i+1] = container[last_index];
    container[last_index] = temp_2;

    return i+1;
    }
    function My_Quick_Sort(container, first_index, last_index) {
    if (first_index < last_index) {
    var mid = My_Partition(container, first_index, last_index);
    My_Quick_Sort(container, first_index, mid-1);
    My_Quick_Sort(container, mid+1, last_index);
    }
    }
    My_Quick_Sort(sample_arr, 0, sample_arr.length-1);
    console.WriteLine("Sorted Array:", sample_arr);
    ```
    as well as following ClearScript's V8 engine configuration:
    ```
    Using engine As New V8ScriptEngine("V8Engine", New V8RuntimeConstraints() With {.MaxOldSpaceSize = 209715200}, V8ScriptEngineFlags.EnableDebugging, 9222)
    ```
    You'll notice that after running above code in 5.3.9 it gracefully ends up with an exception that indicates a memory limit being exceeded (see attachment). However, in 5.3.10 it doesn't result in exception and rather hard-crashes with a message in the console (see attachment). Could you test it on your end and provide some follow-up?

    System used for testing: Window 7, 64 bit.

    Thanks for your work,
    Max


    0 0

    Hi everybody,

    I just noticed a behavior that differs between ClearScript v 5.3.9 and 5.3.10, and it's about limiting memory for a script execution. Consider following faulty script (it emulates a memory leak) being executed inside the 64 bit console application:
    ```
    var sample_arr = [-1, 5, 7, 4, 0, 1, -5]
    function My_Partition(container, first_index, last_index) {
    var x = container[last_index];
    var i = first_index - 1;

    for (var elem = 0; elem < container.length-1; elem++) {
    if (container[elem] <= x) {
    i += 1;
    var temp_1 = container[i];
    container[i] = container[elem];
    container[elem] = temp_1;
    }
    }
    var temp_2 = container[i+1];
    container[i+1] = container[last_index];
    container[last_index] = temp_2;

    return i+1;
    }
    function My_Quick_Sort(container, first_index, last_index) {
    if (first_index < last_index) {
    var mid = My_Partition(container, first_index, last_index);
    My_Quick_Sort(container, first_index, mid-1);
    My_Quick_Sort(container, mid+1, last_index);
    }
    }
    My_Quick_Sort(sample_arr, 0, sample_arr.length-1);
    console.WriteLine("Sorted Array:", sample_arr);
    ```
    as well as following ClearScript's V8 engine configuration:
    ```
    Using engine As New V8ScriptEngine("V8Engine", New V8RuntimeConstraints() With {.MaxOldSpaceSize = 209715200}, V8ScriptEngineFlags.EnableDebugging, 9222)
    ```
    You'll notice that after running above code in 5.3.9 it gracefully ends up with an exception that indicates a memory limit being exceeded (see attachment). However, in 5.3.10 it doesn't result in exception and rather hard-crashes with a message in the console (see attachment). Could you test it on your end and provide some follow-up?

    System used for testing: Window 7, 64 bit.

    Thanks for your work,
    Max

    Comments: V8 bug [here](https://code.google.com/p/v8/issues/detail?id=3060).

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: Hi jbrantly, When you get a chance, please take a look at the latter part of [this thread](https://clearscript.codeplex.com/discussions/471622). Do you think the proposed assembly resolver hook will suffice in your scenario?

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: If the proposed hook is added prior to the LoadNativeLibrary() call then I believe that would work (and I'll just do my own LoadLibrary for v8). The point just being that the proposed hook specifically addresses loading the mixed-mode assembly but not necessarily the v8 native library.

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: Yes, the hook would be invoked before the current loading process takes place. Also, the V8 DLL is a dependency of the mixed-mode assembly, so unless you're extracting them to different directories, loading the mixed-mode assembly should automatically bring in the native DLL.

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: I may be missing something, but V8Proxy specifically invokes LoadLibraryW to bring in the V8 DLL (using paths given by GetDirPaths). Are you saying that is not needed? Keep in mind that in my case GetDirPaths would *not* return a valid path to the v8 DLL. To be clear, in my case: ClearScript.dll - Loaded from memory using Assembly.Load(byte[]) ClearScriptV8-64.dll - Loaded from disk in a temporary folder v8-x64.dll - Loaded from disk in a temporary folder GetDirPaths does return the location of the ClearScript.dll but in my case that is not valid since I'm loading from memory.

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: >V8Proxy specifically invokes LoadLibraryW to bring in the V8 DLL (using paths given by GetDirPaths). Are you saying that is not needed? ‚Äč That's correct; in most cases it isn't needed because the two files are in the same place. V8Proxy does what it does to provide optional support for separate placement, which is very unusual. In your case, if you extract both files into the same temporary folder, your assembly resolution handler will just have to load ClearScriptV8-64.dll. The system will automatically bring in the native V8 DLL and its dependencies, and ClearScript's default loading procedure will be skipped.

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: Gotcha. I didn't realize that was the case. That route sounds good to me! Also, as a side note, thanks for ClearScript and your excellent dev relations. I follow the project somewhat and your response times and willingness to help are second to none.

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: Thank you very much! Being able to interact productively with individual developers is one of the nice things about maintaining a small project like this.

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: I was able to test this today. I modified V8Proxy.LoadAssembly(): private static void LoadAssembly() { try { assembly = Assembly.Load("ClearScriptV8"); return; } catch (FileNotFoundException) { } if (LoadNativeLibrary()) ..... Using AssemblyResolve I was able to load ClearScriptV8 and, as you said, it automatically loaded the v8 native DLL and the test passed. Good stuff.

    0 0

    I am currently trying to pass a js array to a C# method.


    Engine.AddHostObject("plotUtility", plotUtility);

    Engine.Evaluate("myData = [ [1,2], [3,4],[5,8] ]" );
    ....
    Engine.Evaluate("plotUtility.plot( myData )");

    Where plotUtility is a c# object with method plot.

    What would be the proper method for converting myData to a C# array? It comes in as a Microsoft.ClearScript.V8.V8ScriptItem which is protected, meaning i can't use it it my PlotUtlity.Plot signature. (e.g. Public void Plot(V8ScriptItem scriptItem) does not work.)

    I can do the following:

    Engine.Evaluate("plotUtility.plot( JSON.stringify(myData ) )");

    and use a c# signature: Public void Plot(string scriptItem), but that seems a bit superfluous.

    Is there a better way to do this where i can preserve the syntax:

    Engine.Evaluate("plotUtility.plot( myData )");

    0 0

    Greetings!

    ClearScript was designed to provide direct access to script objects, without data conversion. For example, you could write your C# class as follows:
    publicclass ConsolePlotUtility {
        publicvoid plot(dynamic data) {
            for (var i = 0; i < data.length; i++)
                Console.WriteLine("({0},{1})", data[i][0], data[i][1]);
        }
    }
    and then use it like this:
    engine.AddHostObject("plotUtility", new ConsolePlotUtility());
    engine.Evaluate("plotUtility.plot([[1,2], [3,4], [5,8]])");
    Keep in mind, however, that host-to-script and script-to-host calls are relatively expensive. Data conversion can actually yield better performance in many cases. With JSON, for example, you can package your data and move it across the boundary in one step, but of course you have to weigh that against the costs of JSON serialization and parsing.

    Good luck, and thanks for your question!

    0 0

    I am bundling the ClearScript DLLs as embedded resources in my main application/dll. At runtime I extract ClearScriptV8-XX.dll and v8-xXX.dll to a temporary path (typically Temporary ASP.NET Files) so that they can be loaded from disk.

    In order to support this I have added a simple static API which allows adding custom locations returned by V8Proxy.GetDirPaths. It would be ideal if some equivalent functionality were included in the library.

    This issue is somewhat related to https://clearscript.codeplex.com/workitem/17
    Comments: Excellent, thank you! We'll incorporate this change into the next ClearScript release.

    0 0

    Hi,

    I'm using a library (CSG.js) and I need to call it from .Net. I instantiate a few objects and do operation on them. The information on what object and how I combine them comes from .Net. I'm having problem figuring how to do this.

    I'm getting this error: 'Microsoft.ClearScript.Undefined' does not contain a definition for 'DoStuff'

    Here's a simplified sample of what I'm doing.
            V8ScriptEngine engine;
    
            engine = new V8ScriptEngine(V8ScriptEngineFlags.EnableDebugging);
    
            engine.Execute(@"MyClass = function() {
                                    this.First = [];
                                    this.Second = 2;
                                };
    
                                MyClass.prototype = {
                                    DoStuff: function(someInt) {
                                        var mc = new MyClass();
                                        mc.Second = this.Second + mc.Second;
                                    }
                                };
                                ");
    
            dynamic v1 = engine.Evaluate("new MyClass();");
    
            dynamic v2 = engine.Evaluate("new MyClass();");
    
            dynamic res = engine.Script.v1.DoStuff(2);
    
            Console.WriteLine((int)res);
    
    Thanks

    0 0

    Hi ssylvain,

    First, you probably need to add a return statement to DoStuff; otherwise it returns undefined.

    Next, you're getting the error because v1 is a .NET variable, but engine.Script.v1 tries to retrieve a nonexistent global value named v1 from the script engine.

    You probably either want to do something like this:
    dynamic v1 = engine.Evaluate("new MyClass()");
    var res1 = (int)v1.DoStuff(2);
    Console.WriteLine(res1);
    or something like this:
    engine.Evaluate("v2 = new MyClass()");
    var res2 = Convert.ToInt32(engine.Evaluate("v2.DoStuff(2)"));
    Console.WriteLine(res2);
    Cheers!

    0 0
  • 12/23/13--22:16: New Post: Strong Name
  • Hi,

    Is it possible to get a strong named version of ClearScript? I want to use it in a Visual Studio extension, which requires the assembly (and hence all its dependencies) to be signed. I'm currently using Chakra (IE's engine) via Active Scripting but I'd rather use V8 (especially with all the nice features ClearScript provides).

    Thanks!

    0 0
  • 12/25/13--07:13: New Post: Strong Name
  • Hi Dan15,

    We'll take a look at strong naming for the next release. Originally we weren't sure about the value of strong naming in an open-source project, since we'd be distributing the private key. However, it appears that strong naming is a requirement in a number of deployment scenarios, so it may be useful even without its security guarantees, as long as the user understands that.

    Happy holidays!

    0 0

    I am exposing numerous C# objects to ClearScript using the async/await keywords because they are performing I/O. Will ClearScript properly handle asynchronous methods by returning the thread to the pool properly? Basically I do not want to encounter thread pool starvation due to numerous v8 engines performing I/O at the same time. Thanks!

older | 1 | .... | 12 | 13 | (Page 14) | 15 | 16 | .... | 115 | newer