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

Created 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).

New Post: Global camel case support

0
0
Hello uberclops,

ClearScript 5.4.2 will allow you to specify ScriptAccess defaults at the type and assembly levels. We're tracking the generic binding hook feature here.

Thanks!

Created Unassigned: Official Microsoft.ClearScript{,.V8} nuget packages [78]

0
0
I had assumed that https://www.nuget.org/packages/ClearScript.V8/ and https://www.nuget.org/packages/ClearScript/ were official packages, but on closer inspection they’re obviously not published by Microsoft. Since ClearScript’s namespace is Microsoft.ClearScript, I figure that an official nuget package would be named likewise, but https://www.nuget.org/packages/Microsoft.ClearScript/ does not exist.

Please create an official nuget package and at least once with V8 support. I assume that if ClearScript is written to support runtime modularity, there would be a Microsoft.ClearScript which just has VBScript and JScript support and another package Microsoft.ClearScript.V8 that depends on Microsoft.ClearScript and just provides `V8Runtime` and related types and the v8 binaries. This way, third party utilities to aide with ClearScript integration but don’t care about the underlying scripting engine could just require Microsoft.ClearScript without preventing their users from plugging in V8 and using that.

Commented Unassigned: Official Microsoft.ClearScript{,.V8} nuget packages [78]

0
0
I had assumed that https://www.nuget.org/packages/ClearScript.V8/ and https://www.nuget.org/packages/ClearScript/ were official packages, but on closer inspection they’re obviously not published by Microsoft. Since ClearScript’s namespace is Microsoft.ClearScript, I figure that an official nuget package would be named likewise, but https://www.nuget.org/packages/Microsoft.ClearScript/ does not exist.

Please create an official nuget package and at least once with V8 support. I assume that if ClearScript is written to support runtime modularity, there would be a Microsoft.ClearScript which just has VBScript and JScript support and another package Microsoft.ClearScript.V8 that depends on Microsoft.ClearScript and just provides `V8Runtime` and related types and the v8 binaries. This way, third party utilities to aide with ClearScript integration but don’t care about the underlying scripting engine could just require Microsoft.ClearScript without preventing their users from plugging in V8 and using that.
Comments: We apologize for any inconvenience, but we only offer ClearScript in source code form. If you'd like to use it in your project, we recommend that you build it using the instructions in the [ReadMe](https://clearscript.codeplex.com/SourceControl/latest#ReadMe.txt).

Closed Unassigned: Official Microsoft.ClearScript{,.V8} nuget packages [78]

0
0
I had assumed that https://www.nuget.org/packages/ClearScript.V8/ and https://www.nuget.org/packages/ClearScript/ were official packages, but on closer inspection they’re obviously not published by Microsoft. Since ClearScript’s namespace is Microsoft.ClearScript, I figure that an official nuget package would be named likewise, but https://www.nuget.org/packages/Microsoft.ClearScript/ does not exist.

Please create an official nuget package and at least once with V8 support. I assume that if ClearScript is written to support runtime modularity, there would be a Microsoft.ClearScript which just has VBScript and JScript support and another package Microsoft.ClearScript.V8 that depends on Microsoft.ClearScript and just provides `V8Runtime` and related types and the v8 binaries. This way, third party utilities to aide with ClearScript integration but don’t care about the underlying scripting engine could just require Microsoft.ClearScript without preventing their users from plugging in V8 and using that.

Edited Feature: Official Microsoft.ClearScript{,.V8} nuget packages [78]

0
0
I had assumed that https://www.nuget.org/packages/ClearScript.V8/ and https://www.nuget.org/packages/ClearScript/ were official packages, but on closer inspection they’re obviously not published by Microsoft. Since ClearScript’s namespace is Microsoft.ClearScript, I figure that an official nuget package would be named likewise, but https://www.nuget.org/packages/Microsoft.ClearScript/ does not exist.

Please create an official nuget package and at least once with V8 support. I assume that if ClearScript is written to support runtime modularity, there would be a Microsoft.ClearScript which just has VBScript and JScript support and another package Microsoft.ClearScript.V8 that depends on Microsoft.ClearScript and just provides `V8Runtime` and related types and the v8 binaries. This way, third party utilities to aide with ClearScript integration but don’t care about the underlying scripting engine could just require Microsoft.ClearScript without preventing their users from plugging in V8 and using that.

New Post: Global camel case support

0
0
Awesome, thanks guys! Keep up the good work :)

Reopened Issue: ado com error 0x80070018 [76]

0
0
I am attempting to build a vbscript interface through clearscript that can execute ado queries.

I am testing the scalability of executing a large amount of tests, and am finding that I receive an error when I execute above an uncertain threshold number of threads asynchronously (for me, somewhere around 500) .

The error I am receiving is:
"The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)".

Does anyone have any thoughts as to the root of this issue?
Thanks,

Rob

The code I am running looks like this:

```
public class SCB
{
private Connection GetConn()
{
Connection m_Conn = new ADODB.ConnectionClass();
m_Conn.Mode = ADODB.ConnectModeEnum.adModeRead;
m_Conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
m_Conn.Open("Provider=sqloledb;server=localhost;Database=test;User ID=test;Password=test", "", "", -1);
return m_Conn;
}

[ScriptMember(ScriptMemberFlags.ExposeRuntimeType)]
public Recordset ExecuteQuery(string sQuery)
{
if (string.IsNullOrEmpty(sQuery))
{
throw new Exception("Empty query");
}
try
{
object nullObject;
var m_Conn = GetConn();
Recordset rs = m_Conn.Execute(sQuery, out nullObject, 1);
rs.ActiveConnection = null;
m_Conn.Close();
return rs;
}
catch (Exception e)
{
throw e;
}
}
}


static string code = @"
Function GetUniversalMessage
dim lRS, sMessage, sColour,sTimeout
set lRS = SCB.executeQuery(""SELECT TOP 1 * FROM TBLWORKS"")
End Function
getuniversalmessage()
";

static void Main(string[] args)
{

var tasks = new Task[1000];
for (var index = 0; index < 1000; index++)
{
tasks[index] = Task.Factory.StartNew(DoWork);
}
Task.WaitAll(tasks);
}

public static void DoWork()
{
VBScriptEngine _engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging /*| WindowsScriptEngineFlags.EnableJITDebugging*/);
_engine.AllowReflection = true;
_engine.AddHostObject("SCB", new SCB());

_engine.ExecuteCommand(code);
}



```
Comments: Reactivating to track the addition of defensive code to avoid the exception.

Edited Issue: ado com error 0x80070018 [76]

0
0
I am attempting to build a vbscript interface through clearscript that can execute ado queries.

I am testing the scalability of executing a large amount of tests, and am finding that I receive an error when I execute above an uncertain threshold number of threads asynchronously (for me, somewhere around 500) .

The error I am receiving is:
"The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)".

Does anyone have any thoughts as to the root of this issue?
Thanks,

Rob

The code I am running looks like this:

```
public class SCB
{
private Connection GetConn()
{
Connection m_Conn = new ADODB.ConnectionClass();
m_Conn.Mode = ADODB.ConnectModeEnum.adModeRead;
m_Conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
m_Conn.Open("Provider=sqloledb;server=localhost;Database=test;User ID=test;Password=test", "", "", -1);
return m_Conn;
}

[ScriptMember(ScriptMemberFlags.ExposeRuntimeType)]
public Recordset ExecuteQuery(string sQuery)
{
if (string.IsNullOrEmpty(sQuery))
{
throw new Exception("Empty query");
}
try
{
object nullObject;
var m_Conn = GetConn();
Recordset rs = m_Conn.Execute(sQuery, out nullObject, 1);
rs.ActiveConnection = null;
m_Conn.Close();
return rs;
}
catch (Exception e)
{
throw e;
}
}
}


static string code = @"
Function GetUniversalMessage
dim lRS, sMessage, sColour,sTimeout
set lRS = SCB.executeQuery(""SELECT TOP 1 * FROM TBLWORKS"")
End Function
getuniversalmessage()
";

static void Main(string[] args)
{

var tasks = new Task[1000];
for (var index = 0; index < 1000; index++)
{
tasks[index] = Task.Factory.StartNew(DoWork);
}
Task.WaitAll(tasks);
}

public static void DoWork()
{
VBScriptEngine _engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging /*| WindowsScriptEngineFlags.EnableJITDebugging*/);
_engine.AllowReflection = true;
_engine.AddHostObject("SCB", new SCB());

_engine.ExecuteCommand(code);
}



```

Commented Issue: ado com error 0x80070018 [76]

0
0
I am attempting to build a vbscript interface through clearscript that can execute ado queries.

I am testing the scalability of executing a large amount of tests, and am finding that I receive an error when I execute above an uncertain threshold number of threads asynchronously (for me, somewhere around 500) .

The error I am receiving is:
"The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)".

Does anyone have any thoughts as to the root of this issue?
Thanks,

Rob

The code I am running looks like this:

```
public class SCB
{
private Connection GetConn()
{
Connection m_Conn = new ADODB.ConnectionClass();
m_Conn.Mode = ADODB.ConnectModeEnum.adModeRead;
m_Conn.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
m_Conn.Open("Provider=sqloledb;server=localhost;Database=test;User ID=test;Password=test", "", "", -1);
return m_Conn;
}

[ScriptMember(ScriptMemberFlags.ExposeRuntimeType)]
public Recordset ExecuteQuery(string sQuery)
{
if (string.IsNullOrEmpty(sQuery))
{
throw new Exception("Empty query");
}
try
{
object nullObject;
var m_Conn = GetConn();
Recordset rs = m_Conn.Execute(sQuery, out nullObject, 1);
rs.ActiveConnection = null;
m_Conn.Close();
return rs;
}
catch (Exception e)
{
throw e;
}
}
}


static string code = @"
Function GetUniversalMessage
dim lRS, sMessage, sColour,sTimeout
set lRS = SCB.executeQuery(""SELECT TOP 1 * FROM TBLWORKS"")
End Function
getuniversalmessage()
";

static void Main(string[] args)
{

var tasks = new Task[1000];
for (var index = 0; index < 1000; index++)
{
tasks[index] = Task.Factory.StartNew(DoWork);
}
Task.WaitAll(tasks);
}

public static void DoWork()
{
VBScriptEngine _engine = new VBScriptEngine(WindowsScriptEngineFlags.EnableDebugging /*| WindowsScriptEngineFlags.EnableJITDebugging*/);
_engine.AllowReflection = true;
_engine.AddHostObject("SCB", new SCB());

_engine.ExecuteCommand(code);
}



```
Comments: Reactivating to track the addition of defensive code to avoid the exception.

New Post: Returning syntax error location

0
0
While working on a testing framework that executes JavaScript tests, I wanted to have ClearScript tell me the location of the syntax errors it found. It doesn't.

This is in a non-browser environment. I thought version 5.4.1 would fix it. It doesn't.

A colleague debugged the DLL and discovered that the GetDetails() method in the WindowsScriptEngine class (WindowsScriptEngine.Site.cs) will return either a stackTrace or an error location but not both.

The answer was to rework the try block to be:

try
                {
                    var errorLocation = GetErrorLocation(error);
                    if (!string.IsNullOrWhiteSpace(errorLocation))
                    {
                        message += "\n" + errorLocation;
                    }

                    var stackTrace = engine.GetStackTraceInternal();
                    if (!string.IsNullOrWhiteSpace(stackTrace))
                    {
                        message += "\n" + stackTrace;
                    }

                    return message;

                }
Now it returns both in one message.

New Post: Returning syntax error location

0
0
Hello!

If the stack trace can be retrieved successfully, there should be no need to also retrieve the location string, because the former is a superset of the latter. For example, here's a sample stack trace:
Function expected
    at baz (foo.js:2:28) -> 123()
    at bar (foo.js:5:28) -> baz()
    at foo (foo.js:8:28) -> bar()
    at JScript global code (foo.js:10:24) -> foo()
And here's the location string for the same error:
Function expected
    at (foo.js:2:28) -> 123();
As you can see, the location string is redundant if the stack trace is available. Note that the script engine can detect some errors (such as syntax errors) before it starts executing script code. In that case there's no stack trace, so it makes sense to use the location string.

Thanks!

New Post: Returning syntax error location

0
0

Well, in our case, it did not work that way!

We are using Node.js code to ‘require’ our scripts as in the following stack trace:

ScriptEngineException Error loading module /NativeModeApi.js: Syntax error

at (NativeModeApi.js:38:4) -> try {

at anonymous (anonymous code:3:12) -> __scriptGlobal.executeModule('/NativeModeApi.js',require,exports,module)

at buildModule (modules.js:429:6) -> exports = factory.call(null, module.require, module.exports, module)

at memoizeModule (modules.js:380:8) -> buildModule(cache_memo[id].module, factory)

at eventLoad (modules.js:246:4) -> memoizeModule(id, this, event.target.responseText, false)

at JScript anonymous function (modules.js:14:303) -> return e.apply(this instanceof c ? this : b || window, f.concat(a.call(arguments)))

at JScript anonymous function (modules.js:222:10) -> xhr.send(null)

at require (modules.js:275:8) -> module.load(id, null)

at JScript global code (Script Document [temp]:0:0) -> __scriptTestBase.scanScript(require('NativeModeApi'))

The top line points to the line in the test script at which I purposely introduced a syntax error.

Without the change we made as specified in myoriginal post (i.e. the original 5.4.1 code), the top line, “at (NativeModeApi.js:38:4) -> try {“

Is not present.

New Post: Returning syntax error location

0
0
Hi again,

Is executeModule a .NET method? If so, does it re-enter the script engine internally?

Thanks!

New Post: Returning syntax error location

0
0

Yes, it is a .Net method and yes, it re-enters the script engine.


New Post: Returning syntax error location

0
0
Hi,

I just wanted to chime in here. I am the colleague that pblattnerjr mentions above.

We have exposed a .NET global object through ClearScript which contains a method which loads the contents of a referenced JavaScript module and calls the ScriptEngine.Execute method. We do this so that we can associate a document name with a dynamically loaded module. We used this to create a module loader similar to the node.js require syntax.

From our .NET application we call ScriptEngine.Execute to run JavaScript module, and associate a document name with that module. From that JavaScript module we call a .NET method which executes another JavaScript module. If that secondary JavaScript module contains a SyntaxError, the location is not reported because we have a JavaScript stack trace (due to the first JavaScript module).

New Post: Returning syntax error location

0
0
Hello,

Thanks for describing your scenario.

You're right, it does appear that a syntax error occurring in a nested invocation of the script engine can have a stack trace as well as a useful location string. ClearScript should detect this case and report both.

We'll fix this in the next point release.

Thank again!

New Post: Passing Action/Func into JS?

0
0
Thanks - no I'm doing that. But the problem is I'm passing it to EventEmitter's on() method, which throws if it's not a function. So I guess I'll write a wrapper of some sort. Hopefully apply works...

New Post: How does ClearScript choose which dlls to use? (x32 or x64)

0
0
I'm using ClearScript with the V8 engine and I'm noticing that it's always using the x32 dlls ClearScriptV8-32.dll and v8-ia32.dll. These also require the VC++ redistributable package for x86 machines. ClearScriptV8-64.dll and v8-x64.dll don't seem to be touched, and I'm not sure if these would require the x64 VC++ redistributable instead.

Can I rely on (or configure) this behaviour and not bundle the x64 dlls or the x64 VC++ redistributable to lower the size of my distributed software?

New Post: How does ClearScript choose which dlls to use? (x32 or x64)

0
0
Hi Eniko,

ClearScript's main assembly (ClearScript.dll) is AnyCPU and can therefore be loaded into any kind of process. However, because V8 and ClearScript's V8 interface contain native code, they require separate 32- and 64-bit versions. When instructed to create a V8 script engine or runtime instance, ClearScript checks Environment.Is64BitProcess and loads the appropriate assemblies.

If your application targets only the 32-bit platform, or consists of libraries that can only be loaded into a 32-bit process, then there's no need to distribute ClearScript's 64-bit assemblies.

Cheers!
Viewing all 2297 articles
Browse latest View live




Latest Images