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.14.0 (in Microsoft.VisualStudio.Shell.14.0.dll)

public:
static int CallWithCOMConvention(
	Action^ method,
	bool reportError = false
)

Parameters

method
Type: System::Action^

The method to call.

reportError
Type: System::Boolean

True to report the error

Return Value

Type: System::Int32

Returns the corresponding HRESULT, or else VSConstants.S_OK.

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

or

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

Return to top
Show: