Set ErrorInfo in Marshal.GetHRForException
authorEberhard Beilharz <eb1@sil.org>
Thu, 13 Mar 2014 17:55:39 +0000 (18:55 +0100)
committerEberhard Beilharz <eb1@sil.org>
Thu, 13 Mar 2014 17:55:39 +0000 (18:55 +0100)
commit2d420bfb7a394884b7f8f52368907db186b855d9
treeb76b952f7c6efb5c1c9fd2612a7bcce4a6d92e43
parent554d6abf4c5f3760b4f16973f604cfeb9424329a
Set ErrorInfo in Marshal.GetHRForException

Marshal.GetHRForException had a MonoTODO because it needs to set
the errorinfo object so that exceptions get properly passed to
unmanaged code. Since not all managed exceptions have a corresponding
HR value but we might need to get to the original thrown exception
we implement a ManagedErrorInfo helper class that implements the
IErrorInfo interface but also stores the exception.

In GetExceptionForHR we check if the errorinfo we get is a
ManagedErrorInfo. If it is we return the exception stored in there
(if it converts to the same error code), otherwise we construct a new
exception.
mcs/class/corlib/System.Runtime.InteropServices/ManagedErrorInfo.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mcs/class/corlib/corlib.dll.sources