What is the range of classes included in AllowClr()?

183 Views Asked by At

I have set "AllowClr()" to access classes in a .NET assembly, but I cannot access some classes.

What is the range of classes included in "AllowClr()" ?

static void TestA()
{
    var engine = new Jint.Engine(c => c.AllowClr())
        .SetValue("log", new Action<object>(Console.WriteLine));

    try
    {
        // Good
        engine.Execute(@"log(System.Environment.CurrentDirectory)");
        Console.WriteLine("Step 1 complete.");
        
        // Bad
        engine.Execute(@"log(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)");
        Console.WriteLine("Step 2 complete.");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"EXCEPTION: " + ex.Message);
    }
}

I have confirmed that it can be accessed by adding the following options.

 .AllowClr(typeof(System.Diagnostics.Process).Assembly))

Version: 3.0.0-beta-1914
.NET Framework: 4.8

0

There are 0 best solutions below