In which language? Please be specific.
New Post: function: dynamicly parameters
↧
↧
New Post: Invalid constructor invocation
After we provided a suitable
Console
object, this code worked perfectly with ClearScript 5.3.11. Are you using an older version?↧
New Post: Invalid constructor invocation
i use the latest version
and the Console object is a firebug-console implementation
and the Console object is a firebug-console implementation
↧
New Post: function: dynamicly parameters
in js in clearscript
↧
New Post: function: dynamicly parameters
All JavaScript functions can take any number of arguments. Please see here.
↧
↧
New Post: Invalid constructor invocation
Can you provide more information? Which script engine are you using? How are you exposing
XmlHttpRequest
to the script engine? How are you loading and executing the JavaScript code?↧
New Post: Invalid constructor invocation
i use JScriptEngine
se.AddHostObject("XmlHttpRequest", new XmlHttpRequest());
i execute with: js.Evaluate(Properties.Resources.Run);
i also tried with execute, but same error
se.AddHostObject("XmlHttpRequest", new XmlHttpRequest());
i execute with: js.Evaluate(Properties.Resources.Run);
i also tried with execute, but same error
↧
New Post: Invalid constructor invocation
in c# works the code correctly
↧
New Post: Invalid constructor invocation
Hi furesoft,
You're exposing an object - an instance of the
Good luck!
You're exposing an object - an instance of the
XmlHttpRequest
class. For the new
operator to work, you need to expose the class itself:se.AddHostType("XmlHttpRequest", typeof(XmlHttpRequest));
↧
↧
New Post: Invalid constructor invocation
oh, my bad
thanks
thanks
↧
New Post: Serializing the entire engine
So I know you can't do what the subject suggests.
What I'd like is the next best thing.
I'm trying to save as much of the running engine instance as possible so that I can re-instantiate it later and begin invoking functions. I recognize that I'm going to have to be doing something like scrapping the engine instance's root objects, saving them somehow, and then reinjecting them into the engine before resuming execution of script. So, I'm looking for two things:
1) How do I get access to all root objects from inside the CLR?
2) Any advice on things to look out for? I recognize I'm going to have it tricky with regards to tracking down and persisting references, and especially things like 'this' references in JavaScript, and function instances.
What I'm basically implementing is a W3C user agent for XForms. Imagine it as an actual web browser. Except I need to save my engine state and resume it where its left off. My implementation is basically done, except I'm looking for a suitable JavaScript engine to add into it. ClearScript is nice, but I need to be able to accomplish this.
https://github.com/nxkit/nxkit
What I'd like is the next best thing.
I'm trying to save as much of the running engine instance as possible so that I can re-instantiate it later and begin invoking functions. I recognize that I'm going to have to be doing something like scrapping the engine instance's root objects, saving them somehow, and then reinjecting them into the engine before resuming execution of script. So, I'm looking for two things:
1) How do I get access to all root objects from inside the CLR?
2) Any advice on things to look out for? I recognize I'm going to have it tricky with regards to tracking down and persisting references, and especially things like 'this' references in JavaScript, and function instances.
What I'm basically implementing is a W3C user agent for XForms. Imagine it as an actual web browser. Except I need to save my engine state and resume it where its left off. My implementation is basically done, except I'm looking for a suitable JavaScript engine to add into it. ClearScript is nice, but I need to be able to accomplish this.
https://github.com/nxkit/nxkit
↧
New Post: Serializing the entire engine
Hello!
You can do something like this:
This should return all global properties that aren't standard JavaScript built-ins.
Not knowing what kind of objects might be in your script environment, it's difficult to say. Would you expect many .NET objects, and if so, what types? What about script functions? Some script functions may be serializable, but some may not (e.g., those created via
Good luck, and please let us know if you encounter any specific issues!
1) How do I get access to all root objects from inside the CLR?
You can do something like this:
foreach (var name in engine.Script.GetDynamicMemberNames()) { var obj = engine.Script[name]; // do something with obj }
2) Any advice on things to look out for?
Not knowing what kind of objects might be in your script environment, it's difficult to say. Would you expect many .NET objects, and if so, what types? What about script functions? Some script functions may be serializable, but some may not (e.g., those created via
bind()
). One thing you should definitely avoid is using JSON.stringify()
to serialize .NET objects.Good luck, and please let us know if you encounter any specific issues!
↧
New Post: Calling a generic C# method from javascript
i know i would know too how can i use
↧
↧
New Post: get a list of functions
hi,
how can i get a list of all functions?
how can i get a list of all functions?
- found
↧
New Post: Calling a generic C# method from javascript
One way could be to add a host type and pass it to the generic method ?
↧
New Post: using typescript
Hello furesoft,
The TypeScript compiler generates JavaScript code, which ClearScript should be able to execute. If you'd like use ClearScript to run the TypeScript compiler itself, take a look here.
Good luck!
The TypeScript compiler generates JavaScript code, which ClearScript should be able to execute. If you'd like use ClearScript to run the TypeScript compiler itself, take a look here.
Good luck!
↧
New Post: Calling a generic C# method from javascript
Hello maicalal,
That's correct. Many generic methods don't require explicit type arguments because their type arguments can be inferred from their other arguments. In this case there are no other arguments, so type inference is impossible and an explicit type argument is required.
Here's a simple example:
and then:
In general, to invoke a method that requires explicit type arguments, place the required number of host types at the beginning of the argument list.
Cheers!
One way could be to add a host type and pass it to the generic method ?
That's correct. Many generic methods don't require explicit type arguments because their type arguments can be inferred from their other arguments. In this case there are no other arguments, so type inference is impossible and an explicit type argument is required.
Here's a simple example:
publicclass Factory { public T Create<T>() where T : new() { returnnew T(); } } publicclass SomeClass { // ... }
engine.AddHostObject("factory", new Factory()); engine.AddHostType("SomeClass", typeof(SomeClass)); engine.Execute("obj = factory.Create(SomeClass)");
Cheers!
↧
↧
New Post: Using ClearScript. WebApplication problem
This issue seems a bit of an epic. I've read through and tried a lot of things here, but I'm still unable to run my website.
- Installed via NuGet package (bear with me, I don't think that's the issue -- I even updated this morning)
- Works fine in VS 2013 express on development machine
- Works fine in IIS7 on development machine
- ClearScript v5.3.11.0
- Doesn't run on the server after using web deploy to deploy (debug or release)
-
Server is Windows 2008 R2 Datacenter w/ Web Server Role (IIS7)
Cannot load V8 interface assembly. Load failure information for v8-x64.dll:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\d007e065\a07c7d1b\assembly\dl3\3b1d0932\880b1e76_0e75cf01\v8-x64.dll: The specified module could not be found
C:\inetpub\mysite.com\beta\v8-x64.dll: The specified module could not be found
C:\inetpub\mysite.com\beta\bin\v8-x64.dll: The specified module could not be found
- The files do not exist in the paths mentioned. They do exist in /bin/ClearScript.V8/
-
The dll ClearScript.dll does exist in /bin/
- Copying the requested dlls into the requested paths also generated errors (mentioned in other, older posts)
-
Turning off shadow copy only removed the line about Temporary ASP.NET
↧
New Post: Using ClearScript. WebApplication problem
Hi willeyams,
you can use the AssemblyResolve event to point your application to the correct binaries. I've deployed successfully my ASP.NET application to Azure with this technique. First, you register the event handler in the Application_Start method of your website like this:
Let me know if this helps! Also, note that the assembly resolve event is probably not handled by the NuGet version (which is not officially supported by the developers) - you'll have to get a version from Codeplex.
Best regards,
Andrea
edit: since this is my first post, I'd like to thank the developers of ClearScript for providing such an amazing package. Keep up the good work :-)
you can use the AssemblyResolve event to point your application to the correct binaries. I've deployed successfully my ASP.NET application to Azure with this technique. First, you register the event handler in the Application_Start method of your website like this:
void Application_Start(object sender, EventArgs e)
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
This is the way I'm handling the loading: Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.Contains("ClearScript"))
{
var rootPath = HostingEnvironment.MapPath("/Dependencies");
try
{
_log.Info("Looking for ClearScript in " + Path.Combine(rootPath, "ClearScriptV8-64.dll"));
return Assembly.LoadFile(Path.Combine(rootPath, "ClearScriptV8-64.dll"));
}
catch (Exception e)
{
_log.Error("Cannot load ClearScript64", e);
return Assembly.LoadFile(Path.Combine(rootPath, "ClearScriptV8-32.dll"));
}
}
return null;
}
Clearly, my /Dependencies directory contains ClearScriptV8-xx.dll as well as v8-xxx.dll (which is probably needed only if you are using V8).Let me know if this helps! Also, note that the assembly resolve event is probably not handled by the NuGet version (which is not officially supported by the developers) - you'll have to get a version from Codeplex.
Best regards,
Andrea
edit: since this is my first post, I'd like to thank the developers of ClearScript for providing such an amazing package. Keep up the good work :-)
↧
New Post: Using ClearScript. WebApplication problem
Hello andrea_schirru!
Thank you very much for posting that sample, and for your kind words!
Cheers!
Thank you very much for posting that sample, and for your kind words!
Cheers!
↧
More Pages to Explore .....