IronPython: adding links from the host application

In my application, I use Iron Python to provide scripting capabilities. The problem is that the built-in scripts do not see the links that I linked to the application. The only solution I understand is to manually import them from a script

import clr
clr.AddReference(...)
from ... import ...

but I am reading scripts from files and I do not want to add a bunch of imports like this. So how do I add links from a host application? ScriptEngine / ScriptScope has no associated methods :(

+5
source share
1 answer

You want ScriptRuntime.LoadAssemblyeasy access to your ScriptEngine instance:

engine.Runtime.LoadAssembly(typeof(System.Web.HttpContext).Assembly);
+7
source

All Articles