Name
PreserveSigAttribute
Synopsis
When .NET converts a managed
method signature
to an unmanaged signature, it changes the return value to a parameter
that has the out and retval COM
attributes. Instead of the original return value, the unmanaged
method returns a COM HRESULT. If you want to override this behavior,
attach the PreserveSigAttribute to the method.
Something similar happens when you call unmanaged methods from
managed code. In that case, the [out,
retval] parameter on the COM side becomes the
return value, and an HRESULT that indicates an error condition is
translated into a .NET exception. If you want to be able to access
the HRESULT as a long return value, use the
PreserveSigAttribute on the methods in your COM
interface declaration (see
InterfaceTypeAttribute).
public sealed class PreserveSigAttribute : Attribute { // Public Constructors public PreserveSigAttribute( ); }
Hierarchy
System.Object
→
System.Attribute
→
PreserveSigAttribute
Valid On
Method
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access