我正在C#中开发一个制图应用程序,我计划使用IronPython作为应用程序的脚本扩展。我已经成功地使用IronPython几个月了,大多数用户对它没有任何问题,但是有一小部分用户有问题。
在其中一个人的帮助下,我设法挖掘出异常堆栈跟踪。此异常发生在调用Python.CreateEngine()方法时:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Reflection.TargetInvocationException:
Failed to load language 'IronPython 2.6.2': Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Microsoft.Scripting.Actions.TopNamespaceTracker.PublishComTypes(Assembly interopAssembly)
at IronPython.Runtime.Binding.PythonBinder.DomainManager_AssemblyLoaded(Object sender, AssemblyLoadedEventArgs e)
at IronPython.Runtime.Binding.PythonBinder..ctor(PythonContext pythonContext, CodeContext context)
at IronPython.Runtime.PythonContext..ctor(ScriptDomainManager manager, IDictionary`2 options)
--- End of inner exception stack trace ---
at Microsoft.Scripting.Runtime.LanguageConfiguration.LoadLanguageContext(ScriptDomainManager domainManager, Boolean& alreadyLoaded)
at Microsoft.Scripting.Runtime.DlrConfiguration.LoadLanguageContext(ScriptDomainManager manager, LanguageConfiguration config)
at Microsoft.Scripting.Runtime.DlrConfiguration.TryLoadLanguage(ScriptDomainManager manager, AssemblyQualifiedTypeName providerName, LanguageContext& language)
at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageByTypeName(String providerAssemblyQualifiedTypeName)
at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngineByTypeName(String assemblyQualifiedTypeName)
at IronPython.Hosting.Python.GetEngine(ScriptRuntime runtime)我在谷歌上找不到任何与此相关的信息。关于用户环境的一些信息:
我自己使用Win7 64位,但我没有这样的问题。
发布于 2011-08-08 16:11:24
异常发生在IronPython的COM互操作代码中,但我不完全确定原因--发生异常的代码将COM类型从互操作程序集中提取出来。当异常发生时,您必须(不知怎么地)弄清楚在AppDomain中加载了什么程序集,这可能需要实时调试或定制的IronPython构建。
我不确定这是IronPython中的错误,还是用户机器上有一个令人毛骨悚然的COM对象导致IronPython崩溃,但我猜是后者。
https://stackoverflow.com/questions/6968231
复制相似问题