Python 蟒蛇的例外情况:“;';ExeConfigFilename';参数不能为空";

Python 蟒蛇的例外情况:“;';ExeConfigFilename';参数不能为空";,python,mono,python.net,Python,Mono,Python.net,试图让Flask应用程序调用某个第三方.NET代码。我使用的是我自己在Ubuntu 14.04主机上构建的pythonnet。已尝试开发和掌握分支 该应用程序与Flask内置开发服务器完美配合,默认情况下该服务器在localhost:5000上运行 问题是当我将Apache/WSGI加入混合时。如果有人愿意,我可以继续介绍WSGI配置的细节(实际上是通过Puppet部署的,但这并不重要),但为了简洁起见,我们可以说它是相当标准的。我以前安装过WSGI应用程序。web应用程序在尝试使用某个.NET

试图让Flask应用程序调用某个第三方.NET代码。我使用的是我自己在Ubuntu 14.04主机上构建的pythonnet。已尝试开发和掌握分支

该应用程序与Flask内置开发服务器完美配合,默认情况下该服务器在localhost:5000上运行

问题是当我将Apache/WSGI加入混合时。如果有人愿意,我可以继续介绍WSGI配置的细节(实际上是通过Puppet部署的,但这并不重要),但为了简洁起见,我们可以说它是相当标准的。我以前安装过WSGI应用程序。web应用程序在尝试使用某个.NET对象时崩溃,而该对象又试图反序列化一些发布的JSON。堆栈跟踪如下所示:

   ERROR:SdoEngine:Failed to process request body: System.TypeInitializationException: The type initializer for 'System.Web.Script.Serialization.JavaScriptSerializer' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.ArgumentException: The 'ExeConfigFilename' argument cannot be null.
at System.Configuration.ExeConfigurationHost.CheckFileMap (ConfigurationUserLevel level, System.Configuration.ExeConfigurationFileMap map) <0x401bd900 + 0x00130> in <filename unknown>:0 
at System.Configuration.ExeConfigurationHost.InitForConfiguration (System.String& locationSubPath, System.String& configPath, System.String& locationConfigPath, IInternalConfigRoot root, System.Object[] hostInitConfigurationParams) <0x401bd4d0 + 0x0011c> in <filename unknown>:0 
at System.Configuration.InternalConfigurationSystem.InitForConfiguration (System.String& locationConfigPath, System.String& parentConfigPath, System.String& parentLocationConfigPath) <0x401bd470 + 0x0004d> in <filename unknown>:0 
at System.Configuration.Configuration..ctor (System.Configuration.InternalConfigurationSystem system, System.String locationSubPath) <0x401bd2e0 + 0x0008d> in <filename unknown>:0 
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) <0x401bd060 + 0x0007c> in <filename unknown>:0 
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) <0x401bc720 + 0x002b1> in <filename unknown>:0 
at System.Configuration.ClientConfigurationSystem.get_Configuration () <0x401bc5b0 + 0x00049> in <filename unknown>:0 
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.get_Configuration () <0x401bc5b0 + 0x000c9> in <filename unknown>:0 
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) <0x401bc530 + 0x0001f> in <filename unknown>:0 
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) <0x401bc3a0 + 0x00037> in <filename unknown>:0 
at System.Web.Script.Serialization.JavaScriptSerializer..ctor (System.Web.Script.Serialization.JavaScriptTypeResolver resolver, Boolean registerConverters) <0x401bbe60 + 0x0006c> in <filename unknown>:0 
at System.Web.Script.Serialization.JavaScriptSerializer..cctor () <0x401bbde0 + 0x00032> in <filename unknown>:0 
--- End of inner exception stack trace ---
at StormTestCoreLib.ScreenDefinition.ScreenDef.DeSerialize (System.String serializedObject) <0x401bbae0 + 0x00045> in <filename unknown>:0 
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x401b0780 + 0x000b7> in <filename unknown>:0 
错误:SdoEngine:无法处理请求正文:System.TypeInitializationException:“System.Web.Script.Serialization.JavaScriptSerializer”的类型初始值设定项引发异常。-->System.Configuration.ConfigurationErrorsException:初始化配置系统时出错。-->System.ArgumentException:“ExeConfigFilename”参数不能为null。
在0中的System.Configuration.ExecutionConfiguration Host.CheckFileMap(配置用户级别,System.Configuration.ExecutionConfiguration文件映射)处
位于:0中的System.Configuration.ExecConfigurationHost.InitForConfiguration(System.String&locationSubPath,System.String&configPath,System.String&locationConfigPath,IInternalConfigRoot,System.Object[]hostInitConfigurationParams)
位于:0中的System.Configuration.InternalConfigurationSystem.InitForConfiguration(System.String&locationConfigPath,System.String&parentConfigPath,System.String&parentLocationConfigPath)处
位于:0中的System.Configuration.Configuration..ctor(System.Configuration.InternalConfigurationSystem系统,System.String位置子路径)
在0中的System.Configuration.InternalConfigurationFactory.Create(System.Type typeConfigHost,System.Object[]hostInitConfigurationParams)处
在0中的System.Configuration.ConfigurationManager.OpenExeConfigurationInternal(ConfigurationUserLevel用户级别,System.Reflection.Assembly调用_Assembly,System.String exePath)处
在System.Configuration.ClientConfigurationSystem.get_配置()中:0
---内部异常堆栈跟踪的结束---
在System.Configuration.ClientConfigurationSystem.get_配置()中:0
在0中的System.Configuration.ClientConfigurationSystem.System.Configuration.InternalConfigSystem.GetSection(System.String configKey)处
在0中的System.Configuration.ConfigurationManager.GetSection(System.String sectionName)处
位于:0中的System.Web.Script.Serialization.JavaScriptSerializer..ctor(System.Web.Script.Serialization.JavaScriptTypeResolver解析器,布尔寄存器转换器)
位于:0中的System.Web.Script.Serialization.JavaScriptSerializer..cctor()处
---内部异常堆栈跟踪的结束---
在0中的StormTestCoreLib.ScreenDefinition.ScreenDef.DeSerialize(System.String serializedObject)处
at(包装器管理为本机)System.Reflection.monmethod:InternalInvoke(System.Reflection.monmethod,object,object[],System.Exception&)
位于:0中的System.Reflection.MonMethod.Invoke(System.Object obj、BindingFlags invokeAttr、System.Reflection.Binder Binder、System.Object[]参数、System.Globalization.CultureInfo区域性)
Mono版本是按照www.Mono-project.com/docs/getting start/install/linux/安装的4.2.2版本。我们也从MonoGithub repo的源代码构建了它,并获得了相同的结果。有一个相关的问题在发布时得到了解决,我确实得到了解决。我知道,因为我在mono库上运行了
nm
,并且
mono\u domain\u set\u config
就在那里

我是新来的。这看起来确实像是一个配置问题。我已经比较了开发服务器和WSGI环境变量,没有任何问题。在这一点上,我希望任何人都能给我一些建议


必须删除一些链接。不幸的是,没有足够的声誉。我希望问题是清楚的。

原来这是pythonnet中的一个bug。如果我在其
PyNet\u Init
中添加对
mono\u domain\u set\u config
的调用,问题就会消失

diff --git a/src/monoclr/pynetinit.c b/src/monoclr/pynetinit.c
index eaa1d9c..ed247f2 100644
--- a/src/monoclr/pynetinit.c
+++ b/src/monoclr/pynetinit.c
@@ -31,6 +31,7 @@ PyNet_Args* PyNet_Init(int ext) {
     pn_args->shutdown_name = "Python.Runtime:Shutdown()";

     pn_args->domain = mono_jit_init_version(MONO_DOMAIN, MONO_VERSION);
+    mono_domain_set_config(pn_args->domain, ".", "Python.Runtime.dll.config");