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

**URL:** <https://www.ruby-forum.com/t/how-to-access-the-inner-exception-information-from-net-exceptions/202298>\
**Category:** IronRuby\
**Created:** [January 26, 2011, 2:17pm UTC](https://www.ruby-forum.com/t/how-to-access-the-inner-exception-information-from-net-exceptions/202298 "2011-01-26T14:17:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 26, 2011, 2:17pm UTC](https://www.ruby-forum.com/t/how-to-access-the-inner-exception-information-from-net-exceptions/202298/1 "2011-01-26T14:17:17Z")

</div>

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:in`OnCreateAutomationPeer’  
PresentationCore:0:in `CreateAutomationPeer' PresentationCore:0:in`CreatePeerForElement’  
RibbonControlsLibrary:0:in `OnSelected' RibbonControlsLibrary:0:in`ChangeSelection’  
RibbonControlsLibrary:0:in `CoerceSelectedItem' WindowsBase:0:in`ProcessCoerceValue’  
WindowsBase:0:in `UpdateEffectiveValue' WindowsBase:0:in`SetValueCommon’  
WindowsBase:0:in `SetValue' RibbonControlsLibrary:0:in`set\_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:in`load\_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:in`each\_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:in`initialize’  
WindowsBase:0:in `InternalRealCall' WindowsBase:0:in`TryCatchWhen’  
WindowsBase:0:in `InvokeImpl' WindowsBase:0:in`InvokeInSecurityContext’  
mscorlib:0:in `runTryCode' mscorlib:0:in`ExecuteCodeWithGuaranteedCleanup’  
mscorlib:0:in `RunInternal' mscorlib:0:in`Run’  
mscorlib:0:in `Run' WindowsBase:0:in`Invoke’  
WindowsBase:0:in `ProcessQueue' WindowsBase:0:in`WndProcHook’  
WindowsBase:0:in `WndProc' WindowsBase:0:in`DispatcherCallbackOperation’  
WindowsBase:0:in `InternalRealCall' WindowsBase:0:in`TryCatchWhen’  
WindowsBase:0:in `InvokeImpl' WindowsBase:0:in`SubclassWndProc’  
WindowsBase:0:in `DispatchMessage' WindowsBase:0:in`PushFrameImpl’  
WindowsBase:0:in `PushFrame' WindowsBase:0:in`Run’  
PresentationFramework:0:in `RunDispatcher' PresentationFramework:0:in`RunInternal’  
PresentationFramework:0:in `Run’

---

<div class="post-metadata">

**Author:** ![Sick\_Boy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@Sick\_Boy](https://www.ruby-forum.com/u/Sick_Boy)\
**Post date:** [January 26, 2011, 2:48pm UTC](https://www.ruby-forum.com/t/how-to-access-the-inner-exception-information-from-net-exceptions/202298/2 "2011-01-26T14:48:06Z")

</div>

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: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
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:in`OnCreateAutomationPeer’  
PresentationCore:0:in `CreateAutomationPeer' PresentationCore:0:in`CreatePeerForElement’  
RibbonControlsLibrary:0:in `OnSelected' RibbonControlsLibrary:0:in`ChangeSelection’  
RibbonControlsLibrary:0:in `CoerceSelectedItem' WindowsBase:0:in`ProcessCoerceValue’  
WindowsBase:0:in `UpdateEffectiveValue' WindowsBase:0:in`SetValueCommon’  
WindowsBase:0:in `SetValue' RibbonControlsLibrary:0:in`set\_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:in`load\_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:in`each\_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:in`initialize’  
WindowsBase:0:in `InternalRealCall' WindowsBase:0:in`TryCatchWhen’  
WindowsBase:0:in `InvokeImpl' WindowsBase:0:in`InvokeInSecurityContext’  
mscorlib:0:in `runTryCode' mscorlib:0:in`ExecuteCodeWithGuaranteedCleanup’  
mscorlib:0:in `RunInternal' mscorlib:0:in`Run’  
mscorlib:0:in `Run' WindowsBase:0:in`Invoke’  
WindowsBase:0:in `ProcessQueue' WindowsBase:0:in`WndProcHook’  
WindowsBase:0:in `WndProc' WindowsBase:0:in`DispatcherCallbackOperation’  
WindowsBase:0:in `InternalRealCall' WindowsBase:0:in`TryCatchWhen’  
WindowsBase:0:in `InvokeImpl' WindowsBase:0:in`SubclassWndProc’  
WindowsBase:0:in `DispatchMessage' WindowsBase:0:in`PushFrameImpl’  
WindowsBase:0:in `PushFrame' WindowsBase:0:in`Run’  
PresentationFramework:0:in `RunDispatcher' PresentationFramework:0:in`RunInternal’  
PresentationFramework:0:in `Run’
