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

New Post: Script CallStack information in a method callback

$
0
0
Thanks guys, this looks good, the downside being it doesn't identify the file names in which the methods are located in in case of multiple files used. If i were to use the
WindowsScriptEngineFlags.EnableDebugging flag would this allow the usage of the debug interfaces somehow? and if so any idea how? (i'm thinking members can be called out trough reflection easy enough, but i can't figure out what exactly gives out the current information)

Edited Feature: V8ScriptEngine does not support stack limits [26]

$
0
0
Hi there,

I'm trying to evaluate how ClearScript's V8 implementation works when it comes to scripts that could contain issues of any kind. One particular case led me to running a script that contains circular reference, such as this one:
```
var cnt=0;
var addCounter=function(){
++cnt;
console.WriteLine('Counter: #'+(cnt));
addCounter();
}
addCounter();
```
When I execute this script via ClearScript.Execute method, I end up with "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll" (InvokeHelpers.cs, line 144 --> var result = method.Invoke(target, finalArgs);) and there is no way to recover from it. Is there anything that could be done to recover from this error without changing a script section above?

Thanks,
Max

Created Feature: API method for collecting a script stack trace [27]

$
0
0
ClearScript collects stack traces during error processing, but an API method exposing this capability for logging purposes would be useful as well.

Edited Feature: API method for collecting a script stack trace [27]

$
0
0
ClearScript collects script stack traces during error processing, but an API method exposing this capability for logging purposes would be useful as well.

New Post: Script CallStack information in a method callback

$
0
0
Enabling debugging makes richer call stack information available, but ClearScript doesn't have a convenient API for retrieving it. You could deliberately throw a script error, catch the exception, and parse the call stack out of IScriptEngineException.ErrorDetails, but we don't recommend it. We're tracking this here.

New Post: Can not use prototype declarations with V8 Engine

$
0
0
Hi.

I've tried to create a simple "class" declaration using prototype declarations and it seems like that V8 engine don't support that.

The C# code is:
using (var engine = new JScriptEngine())
            {
                /* Attach the host functions */
                engine.AddHostObject("host", new HostFunctions());
                engine.AddHostObject("Environment", new HostTypeCollection("mscorlib", "System.Core"));
                
                var assembly = System.Reflection.Assembly.GetExecutingAssembly();
                using (var stream = assembly.GetManifestResourceStream("ClearScriptTests.Scripts.sample.js"))
                using (var reader = new System.IO.StreamReader(stream))
                {
                    engine.Execute(reader.ReadToEnd());
                }
           }
The JS code is (sample.js embedded resource):
var System = Environment.System;
var Console = System.Console;
var Car = (function () {
    function Car(logger, settings) {
    }

    Car.prototype.bar = function () { Console.WriteLine("bar"); }
}());
for (var m in Car) {
    Console.WriteLine("Property: " + m);
}
When I'm changing the engine from V8ScriptEngine to JScriptEngine the code works pefectly. I cane across this when trying to use TypeScript, which uses prototypes too.

Thanks for any feedback!

Created Unassigned: Class Variable passed byval is adjusted in Sub [28]

$
0
0
Passing a variable (Class) to a sub and using the passed variable to make changes results in the calling routine having its copy adjusted suggesting that BYVAL is not being used for Class objects.

Example Code

```
Class Switch
Public Name
Public IP
End Class

sub Test(byval lsw)
lsw.Name = "From Sub"
end sub

set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```

Commented Unassigned: Class Variable passed byval is adjusted in Sub [28]

$
0
0
Passing a variable (Class) to a sub and using the passed variable to make changes results in the calling routine having its copy adjusted suggesting that BYVAL is not being used for Class objects.

Example Code

```
Class Switch
Public Name
Public IP
End Class

sub Test(byval lsw)
lsw.Name = "From Sub"
end sub

set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```
Comments: OK .. Sould have checked this on simple VBSCRIPT first .. Same result when running Native .. Is this possible in VBScript .. Am I missing something?

Commented Unassigned: Class Variable passed byval is adjusted in Sub [28]

$
0
0
Passing a variable (Class) to a sub and using the passed variable to make changes results in the calling routine having its copy adjusted suggesting that BYVAL is not being used for Class objects.

Example Code

```
Class Switch
Public Name
Public IP
End Class

sub Test(byval lsw)
lsw.Name = "From Sub"
end sub

set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```
Comments: Looks to me like I should have checked this first http://computer-programming-forum.com/59-vbscript/73895c1f1448b205.htm

New Post: Can not use prototype declarations with V8 Engine

$
0
0
Hello yahavgb!

We tested your code and got the same results with both script engines: Car is undefined and no output is generated. That makes sense because the code sets Car (the outer one) to the return value of a function that lacks a return statement.

What results are you seeing?

Thanks!

Edited Unassigned: Class Variable passed byval is adjusted in Sub [28]

$
0
0
Passing a variable (Class) to a sub and using the passed variable to make changes results in the calling routine having its copy adjusted suggesting that BYVAL is not being used for Class objects.

Example Code

```
Class Switch
Public Name
Public IP
End Class

sub Test(byval lsw)
lsw.Name = "From Sub"
end sub

set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```

Commented Unassigned: Class Variable passed byval is adjusted in Sub [28]

$
0
0
Passing a variable (Class) to a sub and using the passed variable to make changes results in the calling routine having its copy adjusted suggesting that BYVAL is not being used for Class objects.

Example Code

```
Class Switch
Public Name
Public IP
End Class

sub Test(byval lsw)
lsw.Name = "From Sub"
end sub

set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```
Comments: Hi egooner, Yes, a VBScript object variable holds a _reference_ to the object. The confusing part is that the reference can be passed by value or by reference! You can see the difference by changing `Test` as follows: ``` VB sub Test(byval lsw) set lsw = new Switch lsw.Name = "From Sub" end sub ``` Cheers!

Edited Issue: VBScript engine reports wrong line number on error [24]

$
0
0
An error in the 1st line is reported as being in line 0
An error in the 2nd line is also reported as being in line 0
And error in the 3rd as line 1
And then it increments as you would expect 2,3,4 ...

The JS engine is OK this is only in the VBScript engine.

New Post: problem in a web project, a different thread owns it.

$
0
0
I am working with Visual Studio Web Developer 2010 Express and getting this error.


System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=The calling thread cannot access this object because a different thread owns it.
Source=WindowsBase
StackTrace:
   at System.Windows.Threading.Dispatcher.VerifyAccess()
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.VerifyAccess() in c:\misc\ClearScript2012\ClearScript\Windows\WindowsScriptEngine.cs:line 169
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.ScriptInvoke(Action action) in c:\misc\ClearScript2012\ClearScript\Windows\WindowsScriptEngine.cs:line 490
   at Microsoft.ClearScript.Windows.WindowsScriptEngine.Execute(String documentName, String code, Boolean evaluate, Boolean discard) in c:\misc\ClearScript2012\ClearScript\Windows\WindowsScriptEngine.cs:line 413
   at Microsoft.ClearScript.ScriptEngine.Execute(String documentName, Boolean discard, String code) in c:\misc\ClearScript2012\ClearScript\ScriptEngine.cs:line 483
   at Microsoft.ClearScript.Windows.VBScriptEngine.ExecuteCommand(String command) in c:\misc\ClearScript2012\ClearScript\Windows\VBScriptEngine.cs:line 261
   at MaxRecall.CORE.ZScripting.PrintScriptRun(Int32 Index) in c:\MRC#\CORE\CORE\Scripting.cs:line 1022
   at MaxRecall.CORE.ZGraphics.ZDocPrinter.Run2() in c:\MRC#\CORE\CORE\Graphics.cs:line 362
   at MaxRecall.CORE.ZGraphics.ZDocPrinter.Run() in c:\MRC#\CORE\CORE\Graphics.cs:line 346
   at MaxRecall.Query4A.make_doc_pdf() in c:\MRC#\QUERY\QUERY.cs:line 2108
   at mr4._Default.MRQ() in C:\MRC#\MR4WEB\MR4\mrq.aspx.cs:line 867
   at ASP.mrq_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\MRC#\MR4WEB\MR4\mrq.aspx:line 4
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:

New Post: problem in a web project, a different thread owns it.

$
0
0
I think I figured it and it had nothing to do with clearscript.

Sigh. celebration premature. if the session times out i get the same error.

New Post: problem in a web project, a different thread owns it.

$
0
0
Glad to hear that you figured it out, but yeah, Windows script engines are tricky to use on the server because each instance can only be called on the thread on which it was created. Good luck!

Created Unassigned: 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.

New Post: Using ClearScript. WebApplication problem

$
0
0
Hi, I tried the workaround described but could not get it working. Could be I reference another project with the clearscript assemblies in it? I did not put very much time into it yet. Anyway, it would certainly be good to have a nuget that works for asp net ootb.

The performance when calling a javascript function with the help of ClearScript is great, it should be a lot of use for this in asp net sites. For example to use any js template engine as a asp net mvc view engine.

Thanks

Created Unassigned: Properties of Nullable type [30]

$
0
0
Dear Sir or Madam,
I seems to having problems setting properties of type Nullable<> from within JScript.

Sample script:
```
function foo(obj, propValue)
{
// obj.Prop is declared as of type Nullable<double>
// neither double nor Nullable<double> works for propValue parameter
obj.Prop = propValue;
}

```
Please help,
Yours faithfully

MW

New Post: Using ClearScript. WebApplication problem

$
0
0
Greetings prgjonas!

The procedure above has been used successfully to deploy ClearScript with ASP.NET applications in both IIS and Azure. If it doesn't work for you, we'd love to take a look at your project (or a relevant subset) if that's a possibility.

As for the NuGet package, we don't maintain it. Please consider contacting its owner, either here or at nuget.org.

Good luck!
Viewing all 2297 articles
Browse latest View live




Latest Images