//====================================================================
- // Converts the CLR exception to an HRESULT. This function also sets
- // up an IErrorInfo for the exception.
- //====================================================================
- [System.Security.SecurityCritical] // auto-generated_required
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- public static extern int GetHRForException(Exception e);
-
- //====================================================================
- // Converts the CLR exception to an HRESULT. This function also sets
- // up an IErrorInfo for the exception.
- // This function is only used in WinRT and converts ObjectDisposedException
- // to RO_E_CLOSED
- //====================================================================
- [System.Security.SecurityCritical] // auto-generated_required
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern int GetHRForException_WinRT(Exception e);
-
- //====================================================================
// This method is intended for compiler code generators rather
// than applications.
//====================================================================
#if FEATURE_COMINTEROP
+ //====================================================================
+ // Converts the CLR exception to an HRESULT. This function also sets
+ // up an IErrorInfo for the exception.
+ //====================================================================
+ [System.Security.SecurityCritical] // auto-generated_required
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ public static extern int GetHRForException(Exception e);
+
+ //====================================================================
+ // Converts the CLR exception to an HRESULT. This function also sets
+ // up an IErrorInfo for the exception.
+ // This function is only used in WinRT and converts ObjectDisposedException
+ // to RO_E_CLOSED
+ //====================================================================
+ [System.Security.SecurityCritical] // auto-generated_required
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ internal static extern int GetHRForException_WinRT(Exception e);
+
internal static readonly Guid ManagedNameGuid = new Guid("{0F21F359-AB84-41E8-9A78-36D110E6D2F9}");
//====================================================================
// Dummy implementations of non-portable interop methods that just throw PlatformNotSupportedException
namespace System.Runtime.InteropServices
-{
+{
public static partial class Marshal
{
+ [System.Security.SecurityCritical]
+ public static int GetHRForException(Exception e)
+ {
+ return (e != null) ? e.HResult : 0;
+ }
+
[System.Security.SecurityCriticalAttribute]
public static int AddRef(System.IntPtr pUnk)
{
FCFuncElement("StructureToPtr", MarshalNative::StructureToPtr)
FCFuncElement("ThrowExceptionForHRInternal", MarshalNative::ThrowExceptionForHR)
FCFuncElement("GetExceptionForHRInternal", MarshalNative::GetExceptionForHR)
- FCFuncElement("GetHRForException", MarshalNative::GetHRForException)
- FCFuncElement("GetHRForException_WinRT", MarshalNative::GetHRForException_WinRT)
FCFuncElement("GetDelegateForFunctionPointerInternal", MarshalNative::GetDelegateForFunctionPointerInternal)
FCFuncElement("GetFunctionPointerForDelegateInternal", MarshalNative::GetFunctionPointerForDelegateInternal)
#ifdef FEATURE_COMINTEROP
+ FCFuncElement("GetHRForException", MarshalNative::GetHRForException)
+ FCFuncElement("GetHRForException_WinRT", MarshalNative::GetHRForException_WinRT)
FCFuncElement("GetRawIUnknownForComObjectNoAddRef", MarshalNative::GetRawIUnknownForComObjectNoAddRef)
FCFuncElement("IsComObject", MarshalNative::IsComObject)
FCFuncElement("GetObjectForIUnknown", MarshalNative::GetObjectForIUnknown)