Comments (4)
The errno
module is defined in IronPython.Modules.dll
so I'm guessing that's not getting loaded up properly in your app domain. Unfortunately I haven't been able to reproduce your issue. Could you perhaps provide a more complete example?
from ironpython3.
This is a stripped-down version of my code:
//##############################################
//##############################################
internal class CLS_app_domain_contexts
{
private CLS_Iron_Python_app_domain_context
V___Iron_Python_app_domain_context;
private AppDomain
V__IronPython_NET_AppDomain;
//==============================================
public CLS_app_domain_contexts ()
{
V___app_domain_names = new STR_app_domain_names (99);
V__IronPython_NET_AppDomain
= M_create_domain
(V___app_domain_names.G_IronPython_NET_AppDomain_name);
/** tried >>> M_create_instance_and_unwrap<CLS_Iron_Python_app_domain_context> */
V___Iron_Python_app_domain_context
= M_create_instance_and_unwrap<CLS_Iron_Python_app_domain_context>
(V__IronPython_NET_AppDomain);
/***/
/** also tried >>> M_create_IronPython_instance_and_unwrap */
/** * /
V___Iron_Python_app_domain_context
= M_create_IronPython_instance_and_unwrap
(V__IronPython_NET_AppDomain);
/***/
}
//==============================================
//==============================================
private AppDomain M_create_domain (string P_domain_name)
{
return AppDomain.CreateDomain(P_domain_name);
}
//==============================================
private T_class_type
M_create_instance_and_unwrap<T_class_type>
(AppDomain P_AppDomain)
{
Type L_class_type = typeof(T_class_type);
return
(T_class_type)
P_AppDomain.CreateInstanceAndUnwrap(
//Gets the display name of the assembly.
L_class_type.Assembly.FullName,
// Gets the fully qualified name of the type,
// including its namespace
// but not its assembly.
L_class_type.FullName);
}
//==============================================
//==============================================
private CLS_Iron_Python_app_domain_context
M_create_IronPython_instance_and_unwrap
(AppDomain P_AppDomain)
{
object
U_S_Instance_LIB_DLL
= Activator
.CreateInstance
(P_AppDomain,
"Iron_Python_3_4_DSKT_02, Version=1.0.0.0,"
+ " Culture=neutral, PublicKeyToken=null",
"Iron_Python_3_4_LIB_02.CLS_Iron_Python_app_domain_context")
.Unwrap();
P_AppDomain
.Load ("Iron_Python_3_4_DSKT_02, Version=1.0.0.0,"
+ " Culture=neutral, PublicKeyToken=null");
return U_S_Instance_LIB_DLL as CLS_Iron_Python_app_domain_context;
}
//==============================================
//==============================================
internal object [] M_AD_execute_script_Iron_Python_3
(cls_CSI_eval_01_NTRF [] P_ARY_CSI_eval_01_NTRF)
{
object [] L_return_values = null;
int L_return_value_last_ndx;
STR_exception_std_arg
L2_exception_std_arg,
L_exception_std_arg;
try
{
#if show_messages
MessageBox.Show ("M_AD_execute_script_Iron_Python_3 call ..." +
$" <{P_ARY_CSI_eval_01_NTRF[0].G_code}>");
#endif
V___Iron_Python_app_domain_context
.M_IPAD_execute_script_Iron_Python_3 (P_ARY_CSI_eval_01_NTRF);
// EXCEPTION THROWN on this call >
L_return_values
= V___Iron_Python_app_domain_context.M_IPAD_get_result_set ();
#if show_messages
MessageBox.Show ("M_AD_execute_script_Iron_Python_3 " +
$" L_return_values == null <{L_return_values == null}>");
#endif
if (L_return_values != null)
if ( (L_return_value_last_ndx = L_return_values.Length) > 1 )
if ( L_return_values[--L_return_value_last_ndx] is Exception )
{
Exception
L_xcpt = L_return_values[L_return_value_last_ndx] as Exception;
string [] L_ARY_mssgs = { };
L2_exception_std_arg = new STR_exception_std_arg ();
V___Iron_Python_app_domain_context
.M_IPAD_get_exception_std_arg (ref L2_exception_std_arg);
KwK_exception
L_KwK_exception = new KwK_exception (ref L2_exception_std_arg);
//MessageBox.Show ("U_XSA_link" + L2_exception_std_arg.U_XSA_link);
L_exception_std_arg
= new STR_exception_std_arg
(P_XSA_mssg : L_xcpt.Message,
P_XSA_ARY_mssgs : L_ARY_mssgs,
P_XSA_Exception : L_xcpt,
P_XSA_exception_type
: ENM_exception_type.e38_app_domain_execution_Exception
| ENM_exception_type.e12_fatal_error_Exception);
L_KwK_exception
.add_message_link_set (ref L_exception_std_arg);
throw L_KwK_exception;
}
return L_return_values;
}
catch (Exception L_xcpt)
{
string [] L2_ARY_mssgs = {
$" L_return_values is null "
+ $"<{L_return_values == null}>",
$" V___Iron_Python_app_domain_context is null"
+ $" <{V___Iron_Python_app_domain_context == null}>"
};
#if show_messages
MessageBox.Show ("M_AD_execute_script_Iron_Python_3 " +
$" V__IronPython_NET_AppDomain == null <{V__IronPython_NET_AppDomain == null}>\n"
+ "M_AD_execute_script_Iron_Python_3 " +
$" V___Iron_Python_app_domain_context == null <{V___Iron_Python_app_domain_context == null}>");
#endif
STR_exception_std_arg
L_xcpt_args = new STR_exception_std_arg
(P_XSA_mssg : L_xcpt.Message,
P_XSA_ARY_mssgs : L2_ARY_mssgs,
P_XSA_Exception : L_xcpt,
P_XSA_exception_type :
ENM_exception_type.e38_app_domain_execution_Exception
| ENM_exception_type.e12_fatal_error_Exception);
throw new KwK_exception (ref L_xcpt_args);
}
}
//==============================================
//==============================================
//##############################################
//##############################################
THIS is within the library "Iron_Python_3_4_DSKT_02">>>
//##############################################
//##############################################
internal static class CLS_S_code_execution
{
//==============================================
internal static string
M_generate_call_code_execution (string P_code)
{
string L_code = string.Format("\"\"\"{0}\"\"\"", P_code);
return "GBL_CExeCtx_code_execution_facility"
+ $".EXECUTE_PYTHON_CODE({L_code})";
}
//==============================================
internal static readonly string
def_code_execution_class
//= @"#!/usr/bin/python3
//# latin-1
= @"
import sys
import traceback
import smtplib
import json
class CLS_CExeCtx_source_for_generic_objects(dict):
def __init__(self):
dict.__init__(self)
def to_JSON (self):
return json.dumps(self.__dict__, sort_keys=False, indent=4)
# global GBL_CExeCtx_Extern_Execution_Context_Object
GBL_CExeCtx_Extern_Execution_Context_Object = CLS_CExeCtx_source_for_generic_objects ()
class CLS_CExeCtx_code_execution_facility:
def __init__ (self):
pass
def gather_data_for_error (self, P_xcpt):
self.L_error_obj = CLS_CExeCtx_source_for_generic_objects ()
self.L_error_class = P_xcpt.__class__.__name__
self.L_error_obj.sys_error_repr = str(repr(P_xcpt))
self.L_error_obj.sys_error_class = str(self.L_error_class)
self.detail = P_xcpt.args[0]
self.cl, self.exc, self.tb = sys.exc_info()
self.line_number = traceback.extract_tb(self.tb)[-1][1]
self.L_error_obj.sys_error_message = str(self.detail)
self.L_error_obj.sys_error_line_number = self.line_number
self.L_error_obj.return_mssg_error_class = '*** error class is <' + self.L_error_class + '>'
self.L_error_obj.traceback = traceback.format_exc()
def EXECUTE_PYTHON_CODE (self, P_fn_to_ececute):
try:
exec (P_fn_to_ececute)
GBL_CExeCtx_Extern_Execution_Context_Object \
.sys_execution_successful = True
except Exception as L_xcpt:
GBL_CExeCtx_Extern_Execution_Context_Object \
.sys_execution_successful = False
self.gather_data_for_error (L_xcpt)
GBL_CExeCtx_Extern_Execution_Context_Object \
.XV_Returned_Value_System_Variable \
= self.L_error_obj.to_JSON ()
GBL_CExeCtx_code_execution_facility = CLS_CExeCtx_code_execution_facility()
VPY_returned_val = ' +++++++++++++++++++ class GBL_CExeCtx_code_execution_facility'
";
}
//##############################################
[Serializable]
public class CLS_Iron_Python_app_domain_context : MarshalByRefObject
{
private CLS_Iron_Python_3 V__Iron_Python_3;
private object [] V__ARY_resultSet;
//==============================================
public CLS_Iron_Python_app_domain_context ()
{
V__Iron_Python_3 = new CLS_Iron_Python_3 ();
}
//==============================================
//==============================================
public void M_IPAD_execute_script_Iron_Python_3
(NTF_CSI_eval [] p_ARY_CSI_eval_01_NTRF)
{
V__ARY_resultSet
= V__Iron_Python_3
.M_IP3_IronPython_execute_all_code (p_ARY_CSI_eval_01_NTRF);
#if M_IP3_execute_script_LOG
MessageBox.Show ("M_IPAD_execute_script_Iron_Python_3 " +
$" L_ARY_resultSet == null <{V__ARY_resultSet == null}>");
if (V__ARY_resultSet != null)
MessageBox.Show ("M_IPAD_execute_script_Iron_Python_3 " +
$" L_ARY_resultSet Length <{V__ARY_resultSet.Length}>");
#endif
}
//==============================================
public object [] M_IPAD_get_result_set ()
{
#if M_IP3_execute_script_LOG
MessageBox.Show ("M_IPAD_get_result_set " +
$" V_ARY_resultSet == null <{V__ARY_resultSet == null}>");
if (V__ARY_resultSet != null)
MessageBox.Show ("M_IPAD_get_result_set " +
$" V_ARY_resultSet Length <{V__ARY_resultSet.Length}>");
#endif
return V__ARY_resultSet;
}
//==============================================
public void M_IPAD_get_exception_std_arg
(ref STR_exception_std_arg P_exception_std_arg)
{
V__Iron_Python_3
.M_IP3_get_exception_std_arg (ref P_exception_std_arg);
}
//==============================================
//==============================================
}
//##############################################
internal class CLS_Iron_Python_3 : MarshalByRefObject
{
private const string
V_C_package_path
= @"C:\Dev_LT_02\Solution\packages\IronPython.3.4.1\lib";
private const string
V_C_package_std_lib_path
= @"C:\Dev_LT_02\Solution\packages\IronPython.StdLib.3.4.1";
private const string
V_C_lib_path
= @"C:\Dev_LT_02\Solution\Iron_Python_3_4_DSKT_02\lib";
private ScriptEngine V__script_engine;
private ScriptScope V__scope;
//==============================================
public CLS_Iron_Python_3 ()
{
V__script_engine = Python.CreateEngine();
V__scope = V__script_engine.CreateScope();
var paths = V__script_engine.GetSearchPaths();
paths.Add(V_C_lib_path);
paths.Add(V_C_package_std_lib_path);
paths.Add(V_C_package_path);
V__script_engine.SetSearchPaths(paths);
v_LIST_IP3_resultSet = new List<object> ();
}
//==============================================
//==============================================
public object [] M_IP3_IronPython_execute_all_code
(NTF_CSI_eval [] p_ARY_CSI_eval_01_NTRF)
{
bool L_success;
STR_output_OBJ L_output_OBJ = new STR_output_OBJ ();
v_LIST_IP3_resultSet.Clear ();
// EXCEPTION THROWN on this call >
if ( M_IP3_execute_script
(CLS_S_code_execution.def_code_execution_class)
)
foreach (NTF_CSI_eval L_CSI_eval in p_ARY_CSI_eval_01_NTRF)
{
#if M_IP3_execute_script_LOG
MessageBox.Show ("M_IP3_IronPython_execute_all_code >" + L_CSI_eval.G_code);
#endif
L_success
= M_IP3_IronPy_execute_code
(L_CSI_eval.G_code, ref L_output_OBJ);
#if M_IP3_execute_script_LOG
MessageBox.Show ("L_success >" + L_success);
#endif
if ( ! L_success )
return v_LIST_IP3_resultSet.ToArray ();
L_output_OBJ.GS_CSI_eval = L_CSI_eval;
M_IP3_iron_python_upload_data (ref L_output_OBJ);
}
#if M_IP3_execute_script_LOG
MessageBox.Show ("M_IP3_IronPython_execute_all_code " +
$" v_LIST_IP3_resultSet == null <{v_LIST_IP3_resultSet == null}>");
#endif
return v_LIST_IP3_resultSet.ToArray ();
}
//==============================================
//==============================================
private bool M_IP3_execute_script (string P_code)
{
bool L_success;
ScriptSource L_source = null;
// EXCEPTION THROWN HERE >
try
{
L_source
= V__script_engine.CreateScriptSourceFromString (P_code);
L_source.Execute(V__scope);
L_success = true;
}
catch (Exception L_xcpt)
{
L_success = false;
#if M_IP3_execute_script_LOG
string L_path = @"C:\KwiKKumpute\.KwiKKumpute_logs\a001_exceptions.txt";
string L_mssg = "\n\n >>> " + DateTime.Now
+ "\n >>> " + L_xcpt.Message + "\n" + L_xcpt.StackTrace;
File.WriteAllText (L_path, L_mssg);
MessageBox.Show ("M_IP3_execute_script <1> >>>" + L_xcpt.Message);
#endif
string [] L_ARY_mssgs
= { P_code,
$"V__script_engine is null"
+ $" <{V__script_engine == null}>",
$"L_source is null <{L_source == null}>",
$"V__scope is null <{V__scope == null}>" };
V___exception_std_arg
= new STR_exception_std_arg
(P_XSA_mssg : L_xcpt.Message,
P_XSA_ARY_mssgs : L_ARY_mssgs,
P_XSA_Exception : L_xcpt,
P_XSA_exception_type
: ENM_exception_type.e38_app_domain_execution_Exception
| ENM_exception_type.e12_fatal_error_Exception);
// The ides here is to add the custom exception object to the list.
// That did not work, as the attempt to get the List of objects
// throws an exception.
v_LIST_IP3_resultSet.Add (L_xcpt);
}
return L_success;
}
//==============================================
//==============================================
private void M_IP3_set_return_object_values
(ref STR_output_OBJ PR_output_OBJ)
{
dynamic L_VPY_returned_val;
object L_return_value_obj;
L_VPY_returned_val
= V__scope.GetVariable<object>
("GBL_CExeCtx_Extern_Execution_Context_Object");
L_return_value_obj = L_VPY_returned_val.XV_Returned_Value_System_Variable;
PR_output_OBJ.GS_is_good = L_VPY_returned_val.sys_execution_successful;
PR_output_OBJ.M_try_parse_values (L_return_value_obj.ToString ());
}
//==============================================
//==============================================
}
//##############################################
//##############################################
The code above was working before being moved into an app domain.
from ironpython3.
I believe that I have figured it out. It was a silly mistake on my part.
The code for both the calling code from the main app domain and the app domain that is running IronPython are in (separate) libraries. I installed IronPython in the library, which is why it was building and running (sort of), but did not install it within the main project in which the app is actually running.
I've since installed it, and everything is good.
SORRY for being a nuisance!
from ironpython3.
No worries. Glad you figured it out!
from ironpython3.
Related Issues (20)
- "not a Zip file" - what does it mean?! HOT 2
- input function throws: LookupException: unknown encoding: utf_8 HOT 6
- NullReferenceException while creating IronPython engine in referenced project HOT 4
- No way to programmatically stop execution HOT 8
- future feature is not defined HOT 1
- IronPython
- The ipyc /out: option dose not change the output path of exe host
- IronPython.Runtime.Exceptions.ImportException: 'No module named 'xml.etree.ElementTree'' HOT 5
- Calling method with an argument of ReadOnlySpan<char> throws ArgumentException
- Ironpython version 3.4.1 Exception at runtime console application HOT 1
- big-data examples: using apache beam or spark
- "Index was outside the bounds of the array" exception thrown when importing a class with hundreds of properties HOT 3
- Install setup.py HOT 6
- Extension binder fails to resolve overloads with nested generics
- How to support IronPython 2.7 and 3.4 in one app? HOT 1
- If call Python and there is an infinite loop in Python, where can set the timeout?
- v3: Embedding in a web site - build warnings about WindowsBase HOT 2
- Error with running IronPython 3.4.1 on existing Windows .NET4.7.2 project HOT 1
- Cannot install pip package if package contains native code that should be compiled during install
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ironpython3.