6

In my application I'm using Iron Python to provide scripting capabilities. The problem is that embedded scripts don't see references I've linked to the app. Only solution as I understand is to manually import them from script

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

but I'm reading scripts from files and I don't want to prepend a bunch of imports like this. So how do I add references from host application? ScriptEngine / ScriptScope doesn't look to have any related methods :(

1 Answer 1

8

The method you want is ScriptRuntime.LoadAssembly, easily accessed from your ScriptEngine instance:

engine.Runtime.LoadAssembly(typeof(System.Web.HttpContext).Assembly);
Sign up to request clarification or add additional context in comments.

1 Comment

thank you! somewhy i didn't guess to look into runtime of the engine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.