How to access the inner exception information from .NET exceptions?

Hi,

I am wondering how I can expose the inner exception information within
IronRuby.

My program is throwing an exception only on one user’s computer, the
exception originates in a SelectItem method in WPF
RibbonControlsLibrary, ComboBox.

I am able to catch the exception and log it, by using a begin; (code);
rescue => e; logger.debug [e.class, e.message,
e.backtrace.join("\n")].join(" "); end.

However this seems to only give me superficial information about
exceptions thrown by .NET.
I would like to be able to log all the exception information, incl each
inner exception, so I can evaluate the problem and hopefully solve it.

Is this possible or are there any other suggestions?

Thanks for any help!

This is the current exception output;

System::TypeInitializationException The type initializer for
‘System.Windows.Automation.InvokePatternIdentifiers’ threw an exception.
PresentationCore:0:in Initialize' PresentationCore:0:in.ctor’
PresentationCore:0:in .ctor' PresentationFramework:0:in.ctor’
RibbonControlsLibrary:0:in .ctor' RibbonControlsLibrary:0:inOnCreateAutomationPeer’
PresentationCore:0:in CreateAutomationPeer' PresentationCore:0:inCreatePeerForElement’
RibbonControlsLibrary:0:in OnSelected' RibbonControlsLibrary:0:inChangeSelection’
RibbonControlsLibrary:0:in CoerceSelectedItem' WindowsBase:0:inProcessCoerceValue’
WindowsBase:0:in UpdateEffectiveValue' WindowsBase:0:inSetValueCommon’
WindowsBase:0:in SetValue' RibbonControlsLibrary:0:inset_SelectedItem’
C:/Program Files (x86)/Six
Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/dialog_util.rb:60:in
select_item' C:/Program Files (x86)/Six Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1124:inload_combobox’
C:/Program Files (x86)/Six
Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1051:in
load_data' C:/Program Files (x86)/Six Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1051:ineach_pair’
C:/Program Files (x86)/Six
Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1051:in
load_data' C:/Program Files (x86)/Six Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:174:ininitialize’
WindowsBase:0:in InternalRealCall' WindowsBase:0:inTryCatchWhen’
WindowsBase:0:in InvokeImpl' WindowsBase:0:inInvokeInSecurityContext’
mscorlib:0:in runTryCode' mscorlib:0:inExecuteCodeWithGuaranteedCleanup’
mscorlib:0:in RunInternal' mscorlib:0:inRun’
mscorlib:0:in Run' WindowsBase:0:inInvoke’
WindowsBase:0:in ProcessQueue' WindowsBase:0:inWndProcHook’
WindowsBase:0:in WndProc' WindowsBase:0:inDispatcherCallbackOperation’
WindowsBase:0:in InternalRealCall' WindowsBase:0:inTryCatchWhen’
WindowsBase:0:in InvokeImpl' WindowsBase:0:inSubclassWndProc’
WindowsBase:0:in DispatchMessage' WindowsBase:0:inPushFrameImpl’
WindowsBase:0:in PushFrame' WindowsBase:0:inRun’
PresentationFramework:0:in RunDispatcher' PresentationFramework:0:inRunInternal’
PresentationFramework:0:in `Run’

Answered my own question after inspecting the exception methods, and the
.NET System.Exception class.
Base/Inner exception seems to be what I was mostly after:
logger.debug [ “#{e.class}: #{e.message}”, “Base
Exception: #{e.GetBaseException}”, “Inner Exception:
#{e.InnerException}”, “StackTrace: #{e.StackTrace}”, “Source:
#{e.Source}”, “TargetSite: #{e.TargetSite}”, “Data:
#{e.Data}”, “BackTrace: #{e.backtrace.join(”\n")}"
].join("\n")
From: [email protected]
To: [email protected]
Date: Wed, 26 Jan 2011 13:08:29 +0000
Subject: [Ironruby-core] How to access the inner exception information
from .NET exceptions?

Hi,

I am wondering how I can expose the inner exception information within
IronRuby.

My program is throwing an exception only on one user’s computer, the
exception originates in a SelectItem method in WPF
RibbonControlsLibrary, ComboBox.

I am able to catch the exception and log it, by using a begin; (code);
rescue => e; logger.debug [e.class, e.message,
e.backtrace.join("\n")].join(" "); end.

However this seems to only give me superficial information about
exceptions thrown by .NET.

I would like to be able to log all the exception information, incl each
inner exception, so I can evaluate the problem and hopefully solve it.

Is this possible or are there any other suggestions?

Thanks for any help!

This is the current exception output;

System::TypeInitializationException The type initializer for
‘System.Windows.Automation.InvokePatternIdentifiers’ threw an exception.
PresentationCore:0:in Initialize' PresentationCore:0:in.ctor’
PresentationCore:0:in .ctor' PresentationFramework:0:in.ctor’
RibbonControlsLibrary:0:in .ctor' RibbonControlsLibrary:0:inOnCreateAutomationPeer’
PresentationCore:0:in CreateAutomationPeer' PresentationCore:0:inCreatePeerForElement’
RibbonControlsLibrary:0:in OnSelected' RibbonControlsLibrary:0:inChangeSelection’
RibbonControlsLibrary:0:in CoerceSelectedItem' WindowsBase:0:inProcessCoerceValue’
WindowsBase:0:in UpdateEffectiveValue' WindowsBase:0:inSetValueCommon’
WindowsBase:0:in SetValue' RibbonControlsLibrary:0:inset_SelectedItem’
C:/Program Files (x86)/Six
Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/dialog_util.rb:60:in
select_item' C:/Program Files (x86)/Six Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1124:inload_combobox’
C:/Program Files (x86)/Six
Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1051:in
load_data' C:/Program Files (x86)/Six Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1051:ineach_pair’
C:/Program Files (x86)/Six
Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:1051:in
load_data' C:/Program Files (x86)/Six Updater/Lib/ruby/gems/1.9.1/gems/six-updater-gui-0.2.0/lib/six/updater-gui/ui_logic.rb:174:ininitialize’
WindowsBase:0:in InternalRealCall' WindowsBase:0:inTryCatchWhen’
WindowsBase:0:in InvokeImpl' WindowsBase:0:inInvokeInSecurityContext’
mscorlib:0:in runTryCode' mscorlib:0:inExecuteCodeWithGuaranteedCleanup’
mscorlib:0:in RunInternal' mscorlib:0:inRun’
mscorlib:0:in Run' WindowsBase:0:inInvoke’
WindowsBase:0:in ProcessQueue' WindowsBase:0:inWndProcHook’
WindowsBase:0:in WndProc' WindowsBase:0:inDispatcherCallbackOperation’
WindowsBase:0:in InternalRealCall' WindowsBase:0:inTryCatchWhen’
WindowsBase:0:in InvokeImpl' WindowsBase:0:inSubclassWndProc’
WindowsBase:0:in DispatchMessage' WindowsBase:0:inPushFrameImpl’
WindowsBase:0:in PushFrame' WindowsBase:0:inRun’
PresentationFramework:0:in RunDispatcher' PresentationFramework:0:inRunInternal’
PresentationFramework:0:in `Run’