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

New Post: Returning a derived type with VBScript

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

Thank you very much!

New Post: why no jscript.net?

$
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?

New Post: why no jscript.net?

$
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!

New Post: why no jscript.net?

$
0
0
but you can make it easier and modern to make oop

New Post: why no jscript.net?

$
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?

New Post: Problem with nullable property of object

New Post: can i add my own language?

$
0
0
hi, how can i add own languages to clearscript?

New Post: can i add my own language?

$
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!

New Post: Checking .NET Type

$
0
0
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".

New Post: Checking .NET Type

$
0
0
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!

New Post: Checking .NET Type

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
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!

New Post: Finding Variable References in Code Snippet

$
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.

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
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!

New Post: Finding Variable References in Code Snippet

$
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!

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
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

New Post: Byte converted to Int

$
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.

New Post: Byte converted to Int

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

New Post: A procedure imported by 'ClearScriptV8-64.dll' could not be loaded.

$
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!

New Post: Finding Variable References in Code Snippet

$
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;
Viewing all 2297 articles
Browse latest View live




Latest Images