Share via


ErrorHandler.CallWithCOMConvention Method (Func)

Catches all but critical exceptions and returns the corresponding HRESULT.

Namespace:  Microsoft.VisualStudio
Assembly:  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)

Syntax

'Declaration
Public Shared Function CallWithCOMConvention ( _
    method As Func _
) As Integer
public static int CallWithCOMConvention(
    Func method
)
public:
static int CallWithCOMConvention(
    Func^ method
)
static member CallWithCOMConvention : 
        method:Func -> int 
public static function CallWithCOMConvention(
    method : Func
) : int

Parameters

Return Value

Type: System.Int32
The HRESULT.

Remarks

Use this method when an interop interface might be implemented by managed code and its methods are expected to return HRESULT error codes but also throw exceptions. This method will catch all but critical exceptions and return the corresponding HRESULT for the caught exception.

Examples

Use one of the following:

hr = ErrorHandler.CallWithCOMConvention(delegate() {object.method(param);});} 
hr = ErrorHandler.CallWithCOMConvention(() => object.method(param));}

.NET Framework Security

See Also

Reference

ErrorHandler Class

CallWithCOMConvention Overload

Microsoft.VisualStudio Namespace