Quantcast
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 | .... | 37 | 38 | (Page 39) | 40 | 41 | .... | 115 | newer

    0 0

    Incredible! This is a huge improvement for me and helps me a lot.

    Thank you very much!

    0 0

    hi, why you donĀ“t can imlement jscript.net?

    it makes the engine better oop
    you can check if its a class definition with regex when its true you jscriptcodeprovider to compile it and automate use as type in jscript?

    0 0

    Hi furesoft,

    ClearScript's main goal is to give script languages the ability to access .NET objects and types. Since JScript.NET can already do that, we're not sure what value ClearScript would add to it.

    Cheers!

    0 0

    but you can make it easier and modern to make oop

    0 0

    Not sure what you mean. JScript.NET gives you OOP and full access to .NET objects and types. What value would ClearScript add?

    0 0

    Thanks.

    0 0

    hi, how can i add own languages to clearscript?

    0 0

    Hi furesoft,

    You can provide your own ScriptEngine subclass. Unfortunately your code would have to be integrated with ClearScript itself, because some of ScriptEngine's abstract members are internal, as are most of the helper types that could facilitate your implementation.

    Good luck!

    0 0
  • 06/18/14--08:04: New Post: Checking .NET Type
  • Hi, how do i compare a .NET type in V8ScringEngine?

    For example, i want to compare if thefollowing types are equal

    var x = new Order();
    var y = new Customer();

    if (typeof(x) === typeof(y){

    };

    This will always returns true because typeof(x) or typeof(y) is always an "object".

    0 0
  • 06/18/14--19:23: New Post: Checking .NET Type
  • Hi ravetam,

    If you set ScriptEngine.AllowReflection to true, you can use Object.GetType for his purpose.
    if (x.GetType() === y.GetType()) {
        // do something
    }
    Good luck!

    0 0
  • 06/19/14--08:12: New Post: Checking .NET Type
  • that works, thanks!

    0 0

    This is in web and all works fine if I build and w3wp.exe is not running. If I test the code and then I build while the w3wp.exe is running, you will get the above error. Then I kill the w3wp.exe reload site and it's all great.

    The project setup is:
    • VS 2012
    • Web (mvc 5)
    • Library (where ClearScript is)
    I reference the Library in Web and I add to Web ClearScript.V8 and ClearScript.Manager from NuGet.

    Thanks!

    0 0

    Hi,

    I have small snippets of javascript code that contain 1-10 references to variables that belong to a 6000+ survey. The vast majority of these items do not have values, and even of the ones that do only a small minority (usually no more than 10) are actually referenced in each snippet of code.

    Instantiating all 6000+ variables is proving to be too slow and costly to do for each snippet.

    Is there a way to pull out all the variable references/names in a snippet of code before it is actually executed? That way, I could see which ones were actually required and pre-load their values ahead of the code to be run.

    Otherwise, I fear I'll have to do some sort of string/regex search, which I would like to avoid.

    0 0

    Hello scuty,

    We haven't seen this message before. Is it happening during the build, or after the build when requests come in? A call stack could be very useful.

    Thanks!

    0 0

    Greetings!

    It sounds like you're looking for a JavaScript parsing or code analysis library. Esprima is one that's written in JavaScript.

    Good luck!

    0 0

    It happens if I do this: I build and I open an request and it's all good, then I make a change in the Library (where ClearScript is) and then I debug and I make an request and it dies.

    This is the call stack:
    [FileLoadException: A procedure imported by 'ClearScriptV8-64.DLL' could not be loaded.]
       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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +44
       System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) +155
       System.Reflection.Assembly.LoadFrom(String assemblyFile) +61
       WebActivatorEx.ActivationManager.get_Assemblies() +282
       WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +88
       WebActivatorEx.ActivationManager.RunPreStartMethods(Boolean designerMode) +47
       WebActivatorEx.ActivationManager.Run() +70
    
    [InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: A procedure imported by 'ClearScriptV8-64.DLL' could not be loaded..]
       System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +12602895
       System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12602616
       System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +280
       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): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: A procedure imported by 'ClearScriptV8-64.DLL' could not be loaded..]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12601936
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12441597

    0 0

    Is there anyway I can create a byte object inside V8?

    I tried
    var b = Byte.Parse('162');
    But b has been converted to a Number.

    0 0

    you can add a function
    addhostobject("int", new Func<object, int>(o => Convert.ToInt32(o));

    0 0

    Hi scuty,

    Unfortunately we can't be of much help here. There are no ClearScript frames within the stacks you provided, and the fact that everything works when you restart the web worker indicates that ClearScript is set up and functioning correctly.

    The ASP.NET environment has always been somewhat problematic for ClearScript due to its reliance on mixed-mode and native assemblies. It's possible that ClearScript is incompatible with the "live build" workflow you're using, at least given your current configuration. Also, although we haven't encountered the specific error you're seeing, the ClearScript.V8 NuGet package has known issues with ASP.NET. Please see the long thread here for a discussion of ASP.NET issues and potential solutions.

    Good luck!

    0 0

    Hi,

    I ended up finding out that Jint includes a parser that can do what I was looking for. Here is an example of how I used it:
    List<string> itemRefs = new List<string>();
            JavaScriptParser jpParser = new JavaScriptParser();
    
            Program parsedJS = jpParser.Parse(formulaToEval, new ParserOptions { Comment = true, Source = formulaToEval, Tokens = true, Tolerant = true });
    
            foreach (Token jsToken in parsedJS.Tokens)
            {
                string tokenVal = jsToken.Value.ToString();
    
                if (jsToken.Type != Tokens.Identifier )
                    continue;
    
    
    
                itemRefs.Add(tokenVal );
            }
    
            return itemRefs;

older | 1 | .... | 37 | 38 | (Page 39) | 40 | 41 | .... | 115 | newer