ReturnsHResult
attributeThe ReturnsHResult
attribute is used to mark a method as returning an HRESULT result in COM .
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property)] public class ReturnsHResultAttribute: System.Attribute { public ReturnsHResultAttribute(bool value) {…} public bool Value { get {…} } }
A method that is decorated with the ReturnsHResult
attribute must not have a body. Thus, the ReturnsHResult
attribute may be placed on an interface method or on an extern class methods that have the extern modifier. A compile-time error occurs if any other method declaration includes the ReturnsHResult
attribute.
The example
class interface Interface1 { [ReturnsHResult] int M(int x, int y); }
declares that the M
method of Interface1
returns an HRESULT. The corresponding COM signature for M
is a method that takes three arguments (the two int
arguments x
and y
plus a third argument of type int*
that is used for the return value) and returns an HRESULT.