Wednesday, 15 February 2012

c# - How to host an IronPython engine in a separate AppDomain? -


I am using the code below to execute IronPython scripts on different "appdomain" c #. The scripts that take a short time (at least 3 minutes) perform fine.

(I used this approach to solve the memory leak problem) but if the script throws say an exception takes a long time (more than 5 min) -> System.Runtime.Remoting. RemotingException: object '/011b230e_2f28_4caa_8bbc_92fabb63b311/vhpajnwe48ogwedf6zwikqow_4.rem'

system; Use of Microsoft Namespace PythonHost Sample {Class Program {Static Zero Main (String [] ARGs) {App Domains Sandbox = Appdomain. Crete Dominen ("Sandbox"); Var Engine = IronPathon. Hosting Python.CreateEngine (sandbox); Var Search Path = Engine GetSearchPaths (); SearchPaths.Add (@ "C: \ Python25 \ Lib"); SearchPaths.Add (@ "C: \ RevitPythonShell"); Engine.SetSearchPaths (searchPaths); ScriptScope scope = engine.ExecuteFile ( "C: \ Python25 \ Test.py") // script morethan to execute 5 mi (sleep) ObjectHandle Oh = scope.GetVariableHandle ( "GlobalVariableName" script) // system exception following Throw takes / /System.Runtime.Remoting.RemotingException: // object '/011b230e_2f28_4caa_8bbc_92fabb63b311/vhpajnwe48ogwedf6zwikqow_4.rem' Console.ReadKey (); }}}

InitializeLifetimeServices be null general approach to override and return. I suspect that it is possible in your case. There is another way involved in the App.config file.


No comments:

Post a Comment