JScript.Net and C# Interaction

// lib.cs:

using System;

namespace Library {
  public class TestLib {
    public static void speak(){
       Console.WriteLine(“Hello From CSharp Dll”);
    }
  }
}

// hello.js
import System;
import Library;

var a = {name:’JScript Object in Exe’};
a.foo = function (){
  Console.WriteLine(‘Hello From ‘ + this.name);
};

a.foo();

TestLib.speak();

Compiling:

1. Make sure .Net Framework is in your path

2. csc.exe /t:library lib.cs

3. jsc.exe /r:lib.dll hello.js

4. hello.exe


Posted

in

, ,

by

Tags: