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

Edited Feature: [FEATURE] Support for specifying host method arguments by name [80]

$
0
0
Neither JavaScript nor VBScript have native support for named arguments, but some way to specify host method arguments by name might be useful.

Edited Feature: [FEATURE] C# direct access to TypedArray data [83]

$
0
0
I have a need to pass large amounts of data back and forth between JavaScript and C#. Ideally I would like to create a Float32Array in JavaScript and then access it as a native array or byte array in C#. The JavaScript code would calculate values while the C# code would consume them. I can currently brute force this by accessing elements one at a time, but it is way too slow for arrays of 100k or 1M elements.

V8 has a facility for this via ArrayBuffer::Externalize(). Are there any plans to support this capability in ClearScript? What would be awesome is if I could do something like the following:

V8ScriptEngine engine = new V8ScriptEngine();
engine.Execute("var a = new Float32Array(100000);");

... do something in JavaScript to set array values

// access the array and compute the sum of the values
dynamic a = engine.Script.a;

// this is how I have to get values today and it is too slow for large arrays
double total = 0;
for (int i = 0; i < 100000; i++)
{
total += a[i]; // each call dives into V8 to get an indexed value - slow
}

// this is what I want to do
float[] array = (float[]) engine.Script.a.externalize(); // one call to V8
for (int i = 0; i < 100000; i++)
{
total += array[i]; // fast!
}

This is also basically what browsers do to process data in WebGL. The JavaScript code calls bufferData() with a Typed Array. See https://msdn.microsoft.com/en-us/library/dn302373(v=vs.85).aspx

Edited Feature: [FEATURE] Expose Chakra [29]

$
0
0
It would be great to get access to the IE9+ Chakra engine as a lightweight (in terms of file size), ES5 compatible alternative to V8.

Edited Feature: [FEATURE] Generic binding hook [77]

$
0
0
A way for the client to hook into the member binding process might be a useful addition to ClearScript. It would allow the client to transform member names, modify argument lists, secure access to system members, check permissions, etc. A relevant discussion thread is [here](https://clearscript.codeplex.com/discussions/573614).

Edited Feature: [FEATURE] Permissions support [37]

$
0
0
ClearScript would benefit from Jint-like permissions support, which gives hosts precise control over script sandboxing.

Edited Feature: [FEATURE] Add support for Windows script engine cloning [35]

$
0
0
The `IActiveScript::Clone` method can be used by multithreaded hosts to set up per-thread engine instances. This is a powerful capability that could greatly enhance the use of Windows script engines on the server.

Edited Feature: [FEATURE] Add support for Windows script engine cloning [35]

$
0
0
The `IActiveScript::Clone` method can be used by multithreaded hosts to set up per-thread engine instances. This is a powerful capability that could greatly enhance the use of Windows script engines on the server.

Created Issue: [BUG] Script execution blocks V8 script item finalization [86]

$
0
0
The V8 script item finalizer currently requires a V8 runtime lock. If the runtime is executing a long-running script, it can block the finalization thread and cause out-of-control memory consumption and frequent garbage collection.

New Post: memory leak when passing javascript object to managed code

$
0
0
Hi Tom,

We've looked into this some more and found a serious bug. We're testing a fix that'll make explicit disposal of script items unnecessary, eliminate the GC.WaitForPendingFinalizers() deadlock, and lessen the need to invoke garbage collection manually.

Thanks for bringing it to our attention!

New Post: US-CERT: Vulnerability in the V8 JavaScript engine...

$
0
0
Thank you for details...

Regards,
Max

Created Unassigned: Exception when calling ToString() on Primitive Object [87]

$
0
0
I am trying to call ToString() on an int object and I am getting the following exception

An unhandled exception of type 'Microsoft.ClearScript.ScriptEngineException' occurred in ClearScriptV8-32.dll

Additional information: TypeError: obj.IntTest.ToString is not a function.

Below is a snippet of code which is causing the issue.

__DataObject.cs__

```
using System;
using System.Collections.Generic;

namespace T4EditorTest
{
public class DataObject
{
public DataObject()
{
Children = new List<SubDataObject>();
}

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }

public Char CharTest { get; set; }

public int IntTest { get; set; }

public List<SubDataObject> Children { get; set; }

public string IntTestToString()
{
return IntTest.ToString();
}
}

public class SubDataObject
{
public DataObject Parent { get; set; }

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }
}
}
```
__Calling Code__
```
private static void TestScriptEngine()
{
using (var engine = new V8ScriptEngine())
{
engine.AddHostType(typeof(DataObject));
engine.AddHostType("Console", typeof(Console));

const string script = @"
var obj = new DataObject();
obj.DisplayName = 'Hello, Script Engine.';
Console.WriteLine(obj.DisplayName);
//obj.CharTest = '1';
obj.IntTest = 5;
obj.SystemName = obj.IntTest.ToString();
Console.WriteLine(obj.IntTest);";

engine.Execute(script);

var obj = engine.Script["obj"] as DataObject;
}
}
```

Commented Unassigned: Exception when calling ToString() on Primitive Object [87]

$
0
0
I am trying to call ToString() on an int object and I am getting the following exception

An unhandled exception of type 'Microsoft.ClearScript.ScriptEngineException' occurred in ClearScriptV8-32.dll

Additional information: TypeError: obj.IntTest.ToString is not a function.

Below is a snippet of code which is causing the issue.

__DataObject.cs__

```
using System;
using System.Collections.Generic;

namespace T4EditorTest
{
public class DataObject
{
public DataObject()
{
Children = new List<SubDataObject>();
}

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }

public Char CharTest { get; set; }

public int IntTest { get; set; }

public List<SubDataObject> Children { get; set; }

public string IntTestToString()
{
return IntTest.ToString();
}
}

public class SubDataObject
{
public DataObject Parent { get; set; }

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }
}
}
```
__Calling Code__
```
private static void TestScriptEngine()
{
using (var engine = new V8ScriptEngine())
{
engine.AddHostType(typeof(DataObject));
engine.AddHostType("Console", typeof(Console));

const string script = @"
var obj = new DataObject();
obj.DisplayName = 'Hello, Script Engine.';
Console.WriteLine(obj.DisplayName);
//obj.CharTest = '1';
obj.IntTest = 5;
obj.SystemName = obj.IntTest.ToString();
Console.WriteLine(obj.IntTest);";

engine.Execute(script);

var obj = engine.Script["obj"] as DataObject;
}
}
```
Comments: Greetings! Integers and strings are some of the very few managed data types that ClearScript automatically converts to their script language equivalents, so in this case the expression `obj.IntTest` evaluates to a JavaScript number rather than an instance of System.Int32. You can use JavaScript's [`Object.prototype.toString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString) to convert it to a string. If you'd prefer to use the managed `ToString()`, you can do something like this: ``` C# engine.AddHostObject("host", new HostFunctions()); engine.Execute("result = host.toInt32(obj.IntTest).ToString()"); ``` Good luck!

Edited Issue: V8 debugging host is silent [85]

$
0
0
I have a similar issue as was described by one member in June 10: I cannot connect to V8 host to debug some code.

I launch the application with _V8ScriptEngineFlags.EnableDebugging_ flag. When I connect with telnet/putty to endpoint "127.0.0.1 9222", I get nothing, no "hello" message. The port is opened, I can see that with "netstat"; so the host is listenining. When I use Eclipse to connect to Standalone V8 VM, I get "Timed out waiting for handshake" error.

I use ClearScript 4.5.2 version. Any advice?

Thanks,
Garbielius

Commented Issue: V8 debugging host is silent [85]

$
0
0
I have a similar issue as was described by one member in June 10: I cannot connect to V8 host to debug some code.

I launch the application with _V8ScriptEngineFlags.EnableDebugging_ flag. When I connect with telnet/putty to endpoint "127.0.0.1 9222", I get nothing, no "hello" message. The port is opened, I can see that with "netstat"; so the host is listenining. When I use Eclipse to connect to Standalone V8 VM, I get "Timed out waiting for handshake" error.

I use ClearScript 4.5.2 version. Any advice?

Thanks,
Garbielius
Comments: We can't reproduce the issue and Gabrielius has not responded in 10 days. Marking as resolved.

Commented Unassigned: Exception when calling ToString() on Primitive Object [87]

$
0
0
I am trying to call ToString() on an int object and I am getting the following exception

An unhandled exception of type 'Microsoft.ClearScript.ScriptEngineException' occurred in ClearScriptV8-32.dll

Additional information: TypeError: obj.IntTest.ToString is not a function.

Below is a snippet of code which is causing the issue.

__DataObject.cs__

```
using System;
using System.Collections.Generic;

namespace T4EditorTest
{
public class DataObject
{
public DataObject()
{
Children = new List<SubDataObject>();
}

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }

public Char CharTest { get; set; }

public int IntTest { get; set; }

public List<SubDataObject> Children { get; set; }

public string IntTestToString()
{
return IntTest.ToString();
}
}

public class SubDataObject
{
public DataObject Parent { get; set; }

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }
}
}
```
__Calling Code__
```
private static void TestScriptEngine()
{
using (var engine = new V8ScriptEngine())
{
engine.AddHostType(typeof(DataObject));
engine.AddHostType("Console", typeof(Console));

const string script = @"
var obj = new DataObject();
obj.DisplayName = 'Hello, Script Engine.';
Console.WriteLine(obj.DisplayName);
//obj.CharTest = '1';
obj.IntTest = 5;
obj.SystemName = obj.IntTest.ToString();
Console.WriteLine(obj.IntTest);";

engine.Execute(script);

var obj = engine.Script["obj"] as DataObject;
}
}
```
Comments: Thanks for the response this helps. I am running into some other issues with the native type conversion. When I declare a type of __decimal__ on my class I cannot set the values in the script without getting > Error: Invalid property assignment. It seems to work fine with float or double's though. Many of my classes will have decimals as this is the a type which corresponds to the database columns. Is this a known issue and is there a way around this? Thanks.

Commented Unassigned: Exception when calling ToString() on Primitive Object [87]

$
0
0
I am trying to call ToString() on an int object and I am getting the following exception

An unhandled exception of type 'Microsoft.ClearScript.ScriptEngineException' occurred in ClearScriptV8-32.dll

Additional information: TypeError: obj.IntTest.ToString is not a function.

Below is a snippet of code which is causing the issue.

__DataObject.cs__

```
using System;
using System.Collections.Generic;

namespace T4EditorTest
{
public class DataObject
{
public DataObject()
{
Children = new List<SubDataObject>();
}

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }

public Char CharTest { get; set; }

public int IntTest { get; set; }

public List<SubDataObject> Children { get; set; }

public string IntTestToString()
{
return IntTest.ToString();
}
}

public class SubDataObject
{
public DataObject Parent { get; set; }

public Guid Id { get; set; }

public string SystemName { get; set; }

public string DisplayName { get; set; }

public string Description { get; set; }
}
}
```
__Calling Code__
```
private static void TestScriptEngine()
{
using (var engine = new V8ScriptEngine())
{
engine.AddHostType(typeof(DataObject));
engine.AddHostType("Console", typeof(Console));

const string script = @"
var obj = new DataObject();
obj.DisplayName = 'Hello, Script Engine.';
Console.WriteLine(obj.DisplayName);
//obj.CharTest = '1';
obj.IntTest = 5;
obj.SystemName = obj.IntTest.ToString();
Console.WriteLine(obj.IntTest);";

engine.Execute(script);

var obj = engine.Script["obj"] as DataObject;
}
}
```
Comments: Hi again, As with the integer example above, you can use `HostFunctions.toDecimal()` to convert a numeric value to `System.Decimal` and preserve its type: ``` C# engine.AddHostObject("host", new HostFunctions()); engine.Execute("obj.DecimalValue = host.toDecimal(123.456)"); ``` Cheers!

Created Unassigned: Could not load file or assembly 'ClearScriptV8-32' or one of its dependencies. An attempt was made to load a program with an incorrect format. [88]

$
0
0
Hi,
I am getting "Could not load file or assembly 'ClearScriptV8-32' or one of its dependencies. An attempt was made to load a program with an incorrect format." exception while using ClearScriptV8 for our web server.
I have tried with installing Visual C++ Redistributable for Visual Studio 2012 Update 4 and other versions but the issue is not resolved. Is there any other workaround for it. I am using the latest version of the dll.
Call Stack:
[FileNotFoundException: Could not load file or assembly 'ClearScriptV8-64.DLL' or one of its dependencies. The specified module could not be found.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'ClearScriptV8-64.DLL' or one of its dependencies. The specified module could not be found.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12495956
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +499
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +131
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +331
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'ClearScriptV8-64.DLL' or one of its dependencies. The specified module could not be found.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12617668
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12457285

Thanks,
Subrata Biswas

Edited Issue: Restricted access to non-public accessors of public properties is not enforced [71]

$
0
0
Hi, I'm having an issue with exposed host object which has a property with public getter and private setter.
For example, I can put a script like "SomeObject.Name = ...". Is there a way to prevent this?

```
public class SomeObject
{
private string _name;
public string Name
{
get { return this._name; }
private set { this._name = value; }
}
}
```

And also, If I try to expose an object instance as interface, I still be able to access to the object's members.
For example,
```
public class SomeObject : IInterface
{
private string _name;
public string Name
{
get { return this.Name; }
private set { this._name = value; }
}

public string ToSomeString()
{
return this._name;
}
}

public interface IInterface
{
string ToSomeString();
}
```
```
IInterface obj = new SomeObject();
Engine.AddHostObject("O", obj);
```

I can put script like O.Name = “A”.

Thank you

Edited Feature: Enable simplified syntax for accessing default members [50]

$
0
0
ClearScript doesn't provide any syntactic shortcuts for accessing default members.

This is particularly noticeable with indexers, which currently must be accessed by name. For example, host dictionary indexers are actually named "Item" and support the following syntax (JavaScript):

``` JavaScript
value = dict.Item(key);
value = dict.Item.get(key);
dict.Item.set(key, value);
```

Because `Item` is a default property, it might also make sense to support one or more of the following:

``` JavaScript
value = dict(key)
value = dict.get(key)
dict.set(key, value)
```

Default methods, though rarely used, might also benefit from special handling.

Edited Issue: V8 Debug agent not functioning? [82]

$
0
0
A basic test using "telnet 127.0.0.1 9222" gives:

```
Type:connect
V8-Version:3.30.33.16
Protocol-Version:1
Embedding-Host:CodeTools
Content-Length:0
```

Then enter:

```
Content-Length:46

{"seq":0,"type":"request","command":"version"}
```
I get no response from the debug agent.

Is this basic test valid?

Viewing all 2297 articles
Browse latest View live




Latest Images