Problems with NativeConstructor and arrays in jint .NET4

Sep 15, 2011 at 3:15 PM
Edited Sep 15, 2011 at 3:16 PM

Hi to all,

I encountered some security problems with arrays in a recompiled jint on .NET4

First of all, this is what i did:

1) Open jint solution with visual studio
2) Change framework of application from 2.0 to 4.0
3) Build solution (you only have to change every "Func..." calls into "Delegates.Func...")

Now jint is compiled in .NET4 and seems to work good.

Below the script that gives me problems:

public void Test() {
  const string script = @"
    var b = objTest.getArray();

  new JintEngine()
    .SetParameter("objTest", new ObjTest())
public class ObjTest {
  public string[] getArray() {
    string[] arr = new string[2];
    arr[0] = "aa";
    arr[1] = "aa";
    return arr;

This script fails in a security exception (System.Security.SecurityException: Request failed.)

Error occurs at this line of code (file NativeConstructor.cs line 151):

.Invoke(new object[]{m_marshaller});

It seems like Invoke method needs some permissions, but i don't understand which ones..

I got this problem only with arrays.

Changing back to .NET2 (or disabling security) solves the problem, but i need to use framework 4

Does anyone have an idea/advice of what to do?