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

Commented Unassigned: ClearScript not finding function added dynamically to window object [31]

$
0
0
ClearScript apparently can't find a function added dynamically to the window object.

In a regular html file, I can call "var passwordAnalysis = zxcvbn($(this).val(), penalties);" just fine.

However, I am trying to execute https://raw.github.com/lowe/zxcvbn/master/zxcvbn.js inside a C# project.

I always get the exception:

ScriptEngineException: TypeError: Method or property not found.

I suspect it is because the zxcvbn method is added dynamically.

C# Code is as follows:

using Microsoft.ClearScript;
using Microsoft.ClearScript.V8;

public class RunScripts
{
public void GetPasswordStrength(string password, string[] penalties)
{
using (var engine = new V8ScriptEngine())
{
engine.Execute(ZxcvbnScript);

var result = engine.Script.zxcvbn(password, penalties);
//or
var result = engine.Script.zxcvbn(password);
//or
var result = engine.Script.zxcvbn(password);
}
}
}
Comments: I had actually moved to using an ExpandoObject to add the host object, but not adding a host object at all is even better. Thanks for the tip!

New Post: Duplicate Error throw in JScriptEngine

$
0
0
I initial a .net runtime in a native c++ program. Create two JScript engine in this .net runtime, this two engine is created in individual appdomain. When the engine throw out a exception, the c++ side will receive a _com_error. That's fine.
But the weird part is ,as long as the first engine throw out a exception, if the secone one also throw out a exception, I found the exception is same as the first one! Even I unload the first engine and appdomain, the second engine keep throw out the first engine's exception. What a ghost exception!
I did another experiments. As long as the exception is not throwing out to c++ side (handled inside .NET Runtime), the problem is gone.
V8 Engine doesn't have this problem.

New Post: Duplicate Error throw in JScriptEngine

$
0
0
Hi bonntom,

Wow, that sounds like an interesting issue, and we'd love to try to debug it, but to do that we need a reproducible case. Your scenario is quite unusual and clearly very complex, so it may not be easy for us to replicate. Would you consider sharing (a portion of) your code to speed up the process?

Thanks!

New Post: Using ClearScript. WebApplication problem

$
0
0
Sorry for my late but i have tried the configuration suggested:

In the project(s) where you added the NuGet package, delete the post-build steps that copy ClearScript's native assemblies to $(TargetDir).
Make sure that ClearScript's native assemblies (ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, and v8-x64.dll) do not appear in your web application's output directory ("bin" by default). For some reason ASP.NET just doesn't like mixed-mode assemblies in the output directory.
Add ClearScript's native assemblies as content files at the root of your web application. You should be able to find them in $(SolutionDir)packages\ClearScript.V8.5.3.7.0\tools\native[x86|amd64]. Make sure their "Copy to Output Directory" properties are set to "Do not copy".
Make sure that either Visual Studio 2012 or the Visual C++ Redistributable for Visual Studio 2012 is installed on your deployment machine(s).

and when i execute visual studio in debug mode, in this instruction:

dim v8engine As V8ScriptEngine = New V8ScriptEngine()

i have the following exception:

An exception of type 'System.TypeLoadException' occurred in ClearScript.dll but was not handled in user code

Additional information: Cannot load V8 interface assembly; verify that the following files are installed with your application: ClearScriptV8-32.dll, ClearScriptV8-64.dll, v8-ia32.dll, v8-x64.dll

thanks for help.
Bye

New Post: Using ClearScript. WebApplication problem

$
0
0
Hi niconico49,

Can you tell us more about your project? It appears to be an ASP.NET application written in Visual Basic; is that correct? Are you running into this problem when deploying on your development PC or on another server? Would you consider sharing (part of) your code to help us diagnose the issue?

Thanks!

New Post: Using ClearScript. WebApplication problem

$
0
0
yes is a vb.net project and running in this problem when i launch in my development pc.
Now i've never try to deploy in a iis server, obsiously!!

On the other hand now i try to download the latest version 5.3.10 of the clearscript,
and then try to recompile with v8-support and launch the project in vs 2013 express with the same configuratione...
if i have the same problems, the next things to do is to make a little web project to share

stay tuned.

:)

thanks.

bye

New Post: Using ClearScript. WebApplication problem

$
0
0
Great! Please let us know if you continue experiencing problems after the updates.

New Post: Run simple script

$
0
0
Hi, everyone!
I'm new in using ClearScript. Could you show me how I can run simple script like:

function TestMethod(testObj)
{
//some action
return testObj;
}

without using construction like: "engine.Script.TestMethod(testObj)" ?

Can I somehow pass the string script to method like: "engine.evaluate(stringScript)"? And how to pass json to that method?

New Post: Using ClearScript. WebApplication problem

$
0
0
I download / recompile and launch everything and the problem is in this instruction inside VBProxy.cs:

hLibrary = NativeMethods.LoadLibraryW(path);

inside this function:


private static bool LoadNativeLibrary()
    {
        var hLibrary = IntPtr.Zero;

        var suffix = Environment.Is64BitProcess ? "x64" : "ia32";
        var fileName = "v8-" + suffix + ".dll";

        var paths = GetDirPaths().Select(dirPath => Path.Combine(dirPath, fileName)).Distinct();
        foreach (var path in paths)
        {
            hLibrary = NativeMethods.LoadLibraryW(path);
            if (hLibrary != IntPtr.Zero)
            {
                break;
            }
        }

        return hLibrary != IntPtr.Zero;
    }
but in one path inside the foreach loop ther is EXACTLY the CORRECT path of dll and then the question is:

Why the LoadLibraryW(path) (or LoadLoalibray(path) because i've tried this too) doesn't load the library?

inside the same source there is:
    private static class NativeMethods
    {
        [DllImport("kernel32", ExactSpelling = true)]
        public static extern IntPtr LoadLibraryW(
            [In] [MarshalAs(UnmanagedType.LPWStr)] string path
        );
    }
and because i have windows 7 32 bit is possible that the problem is linked with the kernel32 some unknown and strange behaviour???????

New Post: Run simple script

$
0
0
Hello xtracer!

If you have script code in a string, you can use the Evaluate() method to run it:
string code = @"
    function TestMethod(testObj) 
    { 
        //some action 
        return testObj; 
    }
";

engine.Evaluate(code);
The script code in this case defines a function called TestMethod. To execute that function, you can use additional scripts:
engine.Evaluate("TestMethod(123)");
engine.Evaluate("TestMethod({foo: 123, bar: 'abc'})");
Or, you can use the Script property to execute the function directly, without parsing or compiling additional scripts:
engine.Script.TestMethod(123);
Please let us know if you have additional questions.

Good luck!

New Post: Using ClearScript. WebApplication problem

$
0
0
Hi niconico49,

but in one path inside the foreach loop ther is EXACTLY the CORRECT path of dll and then the question is:
Why the LoadLibraryW(path) (or LoadLoalibray(path) because i've tried this too) doesn't load the library?

This issue has been reported several times, and the cause is always the same - the library can't be loaded because it depends on another library that can't be found.

In all the cases we've investigated so far, the Visual C++ library (msvc*.dll) was the missing piece. The cause was that neither Visual Studio nor the Visual C++ Redistributable Packages were installed.

If you're seeing this problem on a PC with Visual Studio installed, then we have no explanation because we can't reproduce the problem. We'd love to diagnose it for you, but to do that we might have to take a look at your project.

If that's not possible, then we can try to continue by asking more questions. Can you provide the path to the library that fails to load? Feel free to change any directory names that you'd prefer not to reveal. Also, did you build ClearScript, or are you still using the NuGet package? Finally, are you still trying to run your application on your development PC?

Thanks!

New Post: Run simple script

$
0
0
Thank you! This is what I wanted to see.

New Post: Using ClearScript. WebApplication problem

$
0
0
i had installed vs 2013 express and Visual C++ Redistributable Packages 2013
downloaded from here:
http://www.microsoft.com/it-it/download/details.aspx?id=40784

i downloaded the clearscript package from this site and create ClerScriptV8 project with this phase
1) open the vs prompt by this .bat in this location, link in desktop:
"%comspec% /k "C:\Program Files\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"

2) i go to the directory whe i unzipped the ClearScript project by cd , cd etc.. and launched the V8Update.cmd
by the command "V8Update /N"

3) after the creation of v8 project (obviously i had svn installed) i opened by vs2013 express (c++) and compile

4) I copied the all 5 dll (ClearScript, v8-ia32, v8-x64, ClearScriptV8-32, ClearScriptV8-64) in a directory of my web project (vs 2013 vb.net in that case) and added ClearScript as reference and the other 4 dll as resource by select the project (and not the solution) ==> mouse right button ==>add item and select the four dll with this property settings: Copy to Output Directory" properties are set to "Do not copy".

5) after i executed the project, and thanks to the ClearScript.sln (with v8 support obviously) opened i saw the error exposed before, where the path computed in the foreach loop was:

first: the temporary .net directory:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\<Project/Solution Name>\9eb5f2bd\26824334\assembly\dl3\fc7e457e\3ea5541e_1cf7ce01\v8-ia32.dll

second: the root directory of my project (where infact i included the 4 dll as resource, the path was correct, but the NativeMethods.LoadLibraryW(path); doesn't like

third: the bin directory of my project, where the nuget tried to copy by the following task, that i disabled:
<!-- <PostBuildEvent> if not exist "$(TargetDir)" md "$(TargetDir)" xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.10.0\tools\native\x86*.*" "$(TargetDir)" if not exist "$(TargetDir)" md "$(TargetDir)" xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.10.0\tools\native\amd64*.*" "$(TargetDir)" </PostBuildEvent> --> <br/>
<br/>

not satisfied i tried the same in a DESKTOP PROJECT and the result was ok with any kind of tempt:
1) with the copy of the dll in the bin by the:
<PostBuildEvent>
if not exist "$(TargetDir)" md "$(TargetDir)"
xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.10.0\tools\native\x86*." "$(TargetDir)"
if not exist "$(TargetDir)" md "$(TargetDir)"
xcopy /s /y "$(SolutionDir)packages\ClearScript.V8.5.3.10.0\tools\native\amd64
.*" "$(TargetDir)"
</PostBuildEvent>

2) without the point 1) but added the dll as resource in the project

after all this I suppose, like this entire Discussion, that is not a problem of Visual C++ Redistributable Packages but that in web project/solution the:
NativeMethods.LoadLibraryW(path); doesn't load the library
and then:

WHY????????????????????????????????????????

sincerely i'm very fed up!!!

but is not possible to have a single dll with all and avoid the dll hell or in other case two dll clearScript_32 and clearscript_64 to use as reference in function of the operative system, and nothing else?

New Post: Using ClearScript. WebApplication problem

$
0
0
Another idea:

If I'll create a desktop project (console application) or a Class Library (but for this i don't know if ClearScript doesn't have problem) that use clearscript and add this as reference to my web project/solution, for you is possible to avoid (and solve) all the problem exposed in this topic / discussion?

New Post: Using ClearScript. WebApplication problem

$
0
0
Hi niconico49,

Thanks for providing so many details.

We're sorry to hear that this issue is still blocking you, but we still can't reproduce it. On a machine running 32-bit Windows 7 and Visual Studio 2012, we created a Visual Basic ASP.NET project, added a reference to ClearScript.dll, added the other DLLs as content files at the root, and added some code that invokes the V8-based script engine and displays the result in the home page. Everything just works.

Can you think of anything else about your project that might be different or non-standard in any way?

If you can't share your project, one thing we could do is give you a slightly modified version of ClearScript that collects error information returned by the LoadLibraryW function. Are you interested in trying that? It might provide a clue.

Thanks!

New Post: Using ClearScript. WebApplication problem

$
0
0
Infact i thought about that request:

a piece of code where there is an error control about the result of
LoadLibraryW
i tried to use getlasterror but because i don't know the library to include and the howto to use the code, your solution will be very helpful for me!!!

In that case i'll wait for the version of clearscript or, if is more simple for you the piece of code or the class modified VBProxy.cs

it's your choice, thanks.

On the other hand, can you try the same test with Visual Studio 2013 express too?

In any case the question is the same: i'll wait for a version modified of clearscript to obtain the control errors.

Thanks anyway.

Bye

Created Unassigned: Issue with memory leaking scripts: 5.3.9 vs 5.3.10 [32]

$
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)

Edited Unassigned: Issue with memory leaking scripts: 5.3.9 vs 5.3.10 [32]

$
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)

Edited Unassigned: Issue with memory leaking scripts: 5.3.9 vs 5.3.10 [32]

$
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?

Thanks for your work,
Max

Edited Unassigned: Issue with memory leaking scripts: 5.3.9 vs 5.3.10 [32]

$
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

Viewing all 2297 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>