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

    0 0

    Please try the following in V8Proxy.cs.

    First, make sure the NativeMethods class looks like exactly like this:
    privatestaticclass NativeMethods
    {
        [DllImport("kernel32", ExactSpelling = true, SetLastError = true)]
        publicstaticextern IntPtr LoadLibraryW(
            [In] [MarshalAs(UnmanagedType.LPWStr)] string path
        );
    }
    Then, in LoadNativeLibrary, call Marshal.GetLastWin32Error to get the error code when LoadLibraryW fails. For example, the loop might look something like this:
    foreach (var path in paths)
    {
        hLibrary = NativeMethods.LoadLibraryW(path);
        if (hLibrary != IntPtr.Zero)
        {
            break;
        }
    
        var error = Marshal.GetLastWin32Error();
        Console.WriteLine(error); // breakpoint here
    }
    Remember to rebuild everything and update the ClearScript files in your web project. You should then be able to set a breakpoint at the location indicated above and examine the error code. Please let us know what you find!

    Thanks!

    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: Ugh, you're right. ClearScript instructs V8 to report out-of-memory conditions instead of raising fatal errors. Unfortunately, as far as we can tell, it has _never_ been able to do this reliably (see bug [here](http://code.google.com/p/v8/issues/detail?id=2726)). Our guess is that Chrome's multi-process design mitigates the issue and lowers its priority. The bug seems to have gotten worse in recent V8 builds. We don't believe that ClearScript is at fault because downgrading to the older V8 version makes the problem go away. Unfortunately doing so isn't completely trivial because of all the recent breaking changes in the V8 API. We'll see if we can find the exact V8 version that broke your sample script. In the future we may pair ClearScript releases with branched V8 builds that are hopefully more stable than the "stable" trunk. Thanks for reporting this issue!

    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

    I've tried to use the error control and, strange, the only thing i have obtained is error = 0......

    After this, i tried to only change location of my project and, finally everything was OK!!!!!!!!!!!!!!!!!!!!!

    Then i investigated and discovered that the problem was in the path of the location of the project and precisely the presence of "." and/or the "-" character (dot and/or minus to explain).
    For example my path was like:

    C:\Users\development.word1-word2\Desktop\ProjectName

    To conclude i suppose the NativeMethods.LoadLibraryW(path); method doesn't like this strange characters in the path of directory of various dll location and in that case is a LoadLibraryW BUG!!!

    In any case thanks for the help.

    Bye!!!!

    0 0

    I've tried to use the error control and, strange, the only thing i have obtained is error = 0......

    Hmm, are you sure you have SetLastError=true on the DllImport attribute?

    To conclude i suppose the NativeMethods.LoadLibraryW(path); method doesn't like this strange characters in the path of directory of various dll location and in that case is a LoadLibraryW BUG!!!

    This is all very odd. We've tried to replicate your environment by creating a user account with periods and dashes in the name. We then created the VB web project in that user's directory, ensuring that the path to the project included periods and dashes. But we still couldn't reproduce the problem.

    In any case, we're very happy to hear that you found a way forward! Please let us know if you encounter any other issues.

    Thanks!

    0 0

    Hi again!

    To enable ClearScriptV8 assembly loading via AppDomain.AssemblyResolve, we'd like to propose the following new code at the top of V8Proxy.LoadAssembly:
    try
    {
        assembly = Assembly.Load("ClearScriptV8");
        return;
    }
    catch (FileNotFoundException)
    {
    }
    This should allow hosts to override ClearScript's loading process via the event.

    We'd love to hear your thoughts!

    0 0

    Hello!

    I do not understand how to use it. Give an example of use.

    0 0

    If we made the change above, the host could do something like this to override ClearScript's V8 loading process:
    AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
    {
        if (args.Name == "ClearScriptV8")
        {
            return Assembly.LoadFrom(@"C:\Custom\Path\To\ClearScriptV8-64.dll");
        }
    
        returnnull;
    };
    Would that provide the flexibility you were looking for?

    0 0

    I think this is a good option.

    Thanks!

    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: Thanks. Let me know if you can find that "stable" V8 version, so I can build on top of functionality provided by ClearScript 5.3.10.

    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 3.23.0 seems to be the last V8 trunk version that processes your script correctly. It also happens to work with unmodified ClearScript 5.3.10 sources. Run `v8update 17518` and press Y when you get the compatibility warning. Good luck!

    0 0

    When attempting to run in low rights mode I found that the service was unable to access (or possibly create) a folder in the %appdata%/local/microsoft/clearscript/(x64|x86)/(.net version). It seems to create a file called AssemblyTable.bin in that folder. Is it necessary? Is there any way to avoid this and not require administrative access?

    For specifics I'm running this on a server using the AppPoolIdentity. I set the apppool to run under administrator for the first time and then back to apppoolidentity and it works fine.

    I'm not sure what the issue issue just yet but wondering if this is a known issue or not. Couldn't find anything in the issues here on codeplex.

    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: Excellent - thanks a lot!

    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: No problem! Don't forget to rebuild ClearScript after running V8Update.

    0 0

    When attempting to run in low rights mode I found that the service was unable to access (or possibly create) a folder in the %appdata%/local/microsoft/clearscript/(x64|x86)/(.net version). It seems to create a file called AssemblyTable.bin in that folder. Is it necessary? Is there any way to avoid this and not require administrative access?

    For specifics I'm running this on a server using the AppPoolIdentity. I set the apppool to run under administrator for the first time and then back to apppoolidentity and it works fine.

    I'm not sure what the issue issue just yet but wondering if this is a known issue or not. Couldn't find anything in the issues here on codeplex.
    Comments: Greetings! ClearScript has the ability to load assemblies and expose all their public types to a script engine in one step. It allows the host to specify system assemblies by their short names - "mscorlib", "System.Core", etc. - but full names are usually required to actually load them. In order to map short assembly names to full names, ClearScript enumerates the assemblies in the .NET framework directory and builds a table. This can take some time - usually a second or two - so ClearScript saves the table on disk for reuse. This feature predates ClearScript's use in server environments, and we can certainly see how low-rights mode could block its ability to save the assembly table. However, the code is designed to withstand that. Did this issue cause your service to stop functioning? In any case, you can easily avoid this by specifying preloaded assemblies instead of assembly names. That is, instead of this: ``` C# engine.AddHostObject("lib", new HostTypeCollection("mscorlib")); ``` You could do something like this: ``` C# var assembly = typeof(int).Assembly; engine.AddHostObject("lib", new HostTypeCollection(assembly)); ``` Please let us know if this works for you. Cheers!

    0 0

    When attempting to run in low rights mode I found that the service was unable to access (or possibly create) a folder in the %appdata%/local/microsoft/clearscript/(x64|x86)/(.net version). It seems to create a file called AssemblyTable.bin in that folder. Is it necessary? Is there any way to avoid this and not require administrative access?

    For specifics I'm running this on a server using the AppPoolIdentity. I set the apppool to run under administrator for the first time and then back to apppoolidentity and it works fine.

    I'm not sure what the issue issue just yet but wondering if this is a known issue or not. Couldn't find anything in the issues here on codeplex.
    Comments: This explains why it's working for me actually. I had removed the lib declaration as I realized it wasn't required. Adding it back now requires Administrator rights. The assembly type declaration defined in your last sample works perfectly. Thanks for your help!

    0 0

    When attempting to run in low rights mode I found that the service was unable to access (or possibly create) a folder in the %appdata%/local/microsoft/clearscript/(x64|x86)/(.net version). It seems to create a file called AssemblyTable.bin in that folder. Is it necessary? Is there any way to avoid this and not require administrative access?

    For specifics I'm running this on a server using the AppPoolIdentity. I set the apppool to run under administrator for the first time and then back to apppoolidentity and it works fine.

    I'm not sure what the issue issue just yet but wondering if this is a known issue or not. Couldn't find anything in the issues here on codeplex.

    0 0

    When attempting to run in low rights mode I found that the service was unable to access (or possibly create) a folder in the %appdata%/local/microsoft/clearscript/(x64|x86)/(.net version). It seems to create a file called AssemblyTable.bin in that folder. Is it necessary? Is there any way to avoid this and not require administrative access?

    For specifics I'm running this on a server using the AppPoolIdentity. I set the apppool to run under administrator for the first time and then back to apppoolidentity and it works fine.

    I'm not sure what the issue issue just yet but wondering if this is a known issue or not. Couldn't find anything in the issues here on codeplex.
    Comments: No problem! We've taken another look at the assembly table code and identified several places where it can get derailed by permissions issues. We'll make it bulletproof in the next ClearScript release. Thanks for reporting this!

    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: BTW, Max, we'd like to report this regression to the V8 development team. May we use your test script?

    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: Sure, go ahead.

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