Running JS inside C# context

Oct 25, 2011 at 10:19 AM


I'm using context.SetParameter() to set a C# object. The C# object would then load an external .js file and run its content.

Simply put, some js code will call a c# object, which would then again run code on the context object.

Running creates the all-famous 'Object reference not set to an instance of an object' Exception.

Attached code:

public static JavascriptContext context = new JavascriptContext();
private void button1_Click(object sender, EventArgs e)       
   context.SetParameter("ext", new External());

public class External       
   public void Include()
       Form1.context.Run("function hi(){return 'hi';}");

Any help would be appreciated.