Using custom c# Objects inside Jint

Jun 7, 2012 at 11:56 PM
Edited Jun 8, 2012 at 12:41 AM

Iam trying the following code:

 

public class teste
        {
            private int a;

            public int Abc
            {
                get { return a; }
                set { a = value; }
            }
        }

///...

           teste teste = new Program.teste();
            engine = new JintEngine();        
            engine.SetParameter("teste", teste);
                        
            result = engine.Run(@"                            
              return teste.Abc;
            ");

            Console.WriteLine(result); 
            Console.WriteLine(teste.Abc); 

But iam getting: Attempt by method 'DynamicClass.dynamicPropertySetter(Jint.Marshaller, Jint.Native.JsDictionaryObject, Jint.Native.JsInstance)' to access method 'Jint.Marshaller.MarshalJsValue(Jint.Native.JsInstance)' failed.Line: 2 Char: 14No source code available.

I just want to use my c# object inside javascript.

is this the right way ? 

Jun 8, 2012 at 12:44 AM
Edited Jun 8, 2012 at 12:45 AM

Answering my question:

I was defining my class inside of the class i was using to test the project, and that raised the problem:

ex:

namespace JintTests
{
    class Program
    {

      public class teste
     {
              //// ......
     }

        static void Main(string[] args)
        {
            ////using the test inside with JINT
        }
     }
}

Just put the test class outside the  Program class and all worked !