ErrorHandler.CallWithCOMConvention Method (Action, Boolean)

Use this method when an interop interface might be implemented by managed code, and it is expected to return HRESULT error codes but also throws exceptions. This method catches all except the critical exceptions and returns the corresponding HRESULT for the caught exception.

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

Syntax

'Declaration
Public Shared Function CallWithCOMConvention ( _
    method As Action, _
    reportError As Boolean _
) As Integer
public static int CallWithCOMConvention(
    Action method,
    bool reportError
)
public:
static int CallWithCOMConvention(
    Action^ method, 
    bool reportError
)
static member CallWithCOMConvention : 
        method:Action * 
        reportError:bool -> int
public static function CallWithCOMConvention(
    method : Action, 
    reportError : boolean
) : int

Parameters

  • method
    Type: Action

    The method to call.

  • reportError
    Type: Boolean

    True to report the error

Return Value

Type: Int32
Returns the corresponding HRESULT, or else VSConstants.S_OK.

Examples

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

or

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

.NET Framework Security

See Also

Reference

ErrorHandler Class

CallWithCOMConvention Overload

Microsoft.VisualStudio Namespace