Hi,
In the following short test when the script tries to access the method I get a ScriptEngineException:
I also tried adding
Is there a reason why the property is accessible and the method is not?
Thanks a lot,
Ron
In the following short test when the script tries to access the method I get a ScriptEngineException:
"'ClearScriptAccessTest.TestClass.TestMethod()' is inaccessible due to its protection level"However, accessing the property succeeds.
class TestClass
{
public int TestProperty { get; set; }
public void TestMethod()
{
}
}
class Program
{
static void Main(string[] args)
{
using (var engine = new V8ScriptEngine())
{
try
{
TestClass testClass = new TestClass();
engine.AddHostObject("testClass", testClass);
engine.Execute(
@"
testClass.TestProperty = 17;
testClass.TestMethod();
"
);
}
catch (Exception ex)
{
Console.WriteLine("Error: '{0}'", ex.Message);
}
}
}
}
The obvious workaround is to changeclass TestClassto
public class TestClassbut in real life this requires changing many other classes.
I also tried adding
[assembly: InternalsVisibleTo("ClearScript")]
[assembly: InternalsVisibleTo("ClearScriptV8-64")]
[assembly: InternalsVisibleTo("ClearScriptV8-32")]
but that also didn't work.Is there a reason why the property is accessible and the method is not?
Thanks a lot,
Ron