I tried the obvious:
var appDomain = AppDomain.CreateDomain("New Domain"); var engine = IronPython.Hosting.Python.CreateEngine(appDomain);
But I get the following error message: The type is not allowed for the member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup, Microsoft.Scripting, Version = 0.9.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'.
Googling for this mistake did not prove a fruitful sofa ...
EDIT. # one:
I tried to create a project with minimal reproduction by copying the relevant materials to a new console application:
using System; using Microsoft.Scripting; namespace PythonHostSamle { class Program { static void Main(string[] args) { AppDomain sandbox = AppDomain.CreateDomain("sandbox"); var engine = IronPython.Hosting.Python.CreateEngine(sandbox); var searchPaths = engine.GetSearchPaths(); searchPaths.Add(@"C:\Python25\Lib"); searchPaths.Add(@"C:\RevitPythonShell"); engine.SetSearchPaths(searchPaths); var scope = engine.CreateScope();
It works as expected!
Thus, it remains for me to conclude that the error I get is related to one of the lines that I commented on: the area added to the engine contains an object in which I have little control - a link to the host plug-in, this software is designed to run (Autodesk Revit Architecture 2010).
Maybe trying to convey this is what creates the error?
Is there a way to pass proxies instead? (will need to look for remote .NET ...)
EDIT # 2:
I removed the problem before transferring the object through a region that cannot be proxied to another AppDomain: all objects added to the IronPython interpreter region working in another AppDomain must be marshaled somehow and must either be stretched by MarshalByRefObject or be Serializable .
Daren thomas
source share