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 | .... | 7 | 8 | (Page 9) | 10 | 11 | .... | 115 | newer

    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)

    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

    0 0

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

    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.

    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.

    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!

    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
    ```

    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?

    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

    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!

    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
    ```

    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!

    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.

    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:

    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.

    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!

    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.

    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

    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

    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!

older | 1 | .... | 7 | 8 | (Page 9) | 10 | 11 | .... | 115 | newer