Download this assembly. Methods for using. net3.5 and. net4.0 are provided. 1. Download noesis. Javascript. dll2.add referene to the project. 3. Run demo on the official website. 4. Create a console project.
CSJS
Complete code is attached:
After running the command, you can obtain the command line output. Http://javascriptdotnet.codeplex.com/
This is the encapsulation of Google's V8 JavaScript engine, the best JavaScript Engine. With this, we can introduce some existing javascirpt code into the C # code for running.
Project Description
JavaScript. NET integrates Google's V8 JavaScript Engine and exposes it to the CLI environment. javaScript. net compiles (at runtime) and executes scripts directly from. net code. it allows CLI objects to be exposed and manipulated directly from the executed
Javascript. sample "Hello World" running through JavaScript
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Noesis.Javascript;namespace CSJS{ class Program { public class SystemConsole { public SystemConsole() { } public void Print(string iString) { Console.WriteLine(iString); } } static void Main(string[] args) { // Initialize a context JavascriptContext context = new JavascriptContext(); // Setting external parameters for the context context.SetParameter("console", new SystemConsole()); context.SetParameter("message", "Hello World !"); context.SetParameter("number", 1); // Script string script = @" var i; for (i = 0; i < 5; i++) console.Print(message + ' (' + i + ')'); number += i;"; // Running the script context.Run(script); // Getting a parameter Console.WriteLine("number: " + context.GetParameter("number")); } }}