This project is read-only.

DynamicEngine.CreateRuntime don't have options param?

Apr 11, 2011 at 9:25 AM

i have to use the method DynamicEngine.CreateRuntime() instead of Python.CreateRuntime()


ScriptRuntime runtime = Python.CreateRuntime();
dynamic script = runtime.UseFile("");  //When running in Silverlight, it thows "NotImplementedException was unhandled by user code" error

but i need IronPython Script can visit the "internal" field of the class,

i find a passage ,which can slove that problem,the code is:

Dictionary<string, object> options = new Dictionary<string, object>();
.Add("PrivateBinding", true);

var engine
= Python.CreateEngine(options);

but when i use DynamicEngine.CreateRuntime() method ,there is no param for the options 

 i have no idea for this problem ,who can give me some solution,thanks!


Apr 11, 2011 at 4:52 PM

Accessing internal members won't work in Silverlight. It only works in full trust.


Apr 11, 2011 at 6:03 PM
If you want to include options in Silverlight, do this:

var setup = DynamicEngine.CreateRuntimeSetup();
// manipulate setup.Options
var runtime = new ScriptRuntime(setup);

But Tomas is right, PrivateBinding doesn't work in Silverlight. This
is a limitation of Silverlight; here are the security restrictions for
reflection in Silverlight:

Apr 12, 2011 at 2:19 AM

thanks for the suggestions~~