Getting InvaliProgra Exception in Windows Phone 7

Mar 29, 2012 at 7:41 AM

In Windows Phone 7 application I've registered the SyaHelloClass and when I tried to execute SayHello method I'm getting InvalidProgramException. 

following is the code snipest of my appliation:

 
string scriptData = @”function ShowMessage(){ var a = new SayHelloClass();
 a.SayHello(); // This is giving invalidprogramexception.
 }
 
C# code is:
 
public class SayHelloClass()
 {
 public SayHelloClass()
 {
 }
 public SayHello()
 {
 MessageBox.Show(“Hello!”);
 }
 }
 
I’ve registered global settings as follow:
 JintEngine engine = new JintEngine();
 JsConstructor ctor = engine.Global.Marshaller.MarshalType(typeof(HelperClass));
 ((JsObject)engine.Global)["HelperClass"] = ctor;
 
and calling the ShowMessage API as follow:
 engine.Run(“ShowMessage()”);
 
I’ve tried to debug and it is giving exception from NativeMethod.cs class:
 visitor.Return( m_impl(visitor.Global, that, parameters) );
 
What Am I missing here? Does it due to reflection limitations? How can I overcome to this problem?