结合 IronPython 和 CLI 堆栈跟踪
我有一个用 IronPython 编写的应用程序,它使用导入的 .NET 程序集(使用调试支持编译)中的类和方法。当程序集中的方法抛出异常时,它会在 IronPython 代码中作为异常(而不是 System.Exception)捕获,并且回溯在最后一个 IronPython 方法处结束。
我想要做的是更深入地在最后一个 IronPython 方法之后附加原始 CLI 回溯,以查看程序集中发生异常的位置。
是否有可能从捕获的 IronPython 等效项中获取原始 CLI 异常,或者在不丢失 IronPython 堆栈跟踪的情况下捕获它?
谢谢。
I have an application written in IronPython which uses classes and methods from imported .NET assembly (compiled with debug support). When a method in assembly throws an exception, it gets caught in IronPython code as Exception (not System.Exception) and the traceback ends at last IronPython method.
What I would like to do is to go deeper and append the original CLI traceback after last IronPython method to see where the exception occured inside the assembly.
Is it possible to get original CLI exception from caught IronPython equvivalent or catch it without loosing IronPython's stack trace?
Thanx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从 scriptEngine.GetService() 获取 ExceptionOperations 对象。然后您可以调用 FormatException 或 GetStackFrames。您还可以将 ExceptionDetail 选项设置为 true 以从 FormatException 获取更详细的堆栈跟踪。
You can get the ExceptionOperations object from scriptEngine.GetService(). You can then call FormatException or GetStackFrames. You can also set the ExceptionDetail option to true to get more verbose stack traces from FormatException.