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 NotInheritable Class PreserveSigAttribute : Inherits Attribute ' Public Constructors Public Sub New() End Class
Hierarchy
System.Object→System.Attribute→ PreserveSigAttribute
Valid On
Method
Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.