Used to indicate that HResult/retval signature transformation that normally takes place during Interop calls should be suppressed. The attribute affects marshaling as well as type library importing and exporting.
Object
Attribute
PreserveSigAttribute
[Visual Basic] Public Class PreserveSigAttribute Inherits Attribute [C#] public class PreserveSigAttribute : Attribute [C++] public __gc class PreserveSigAttribute : public Attribute [JScript] public class PreserveSigAttribute extends Attribute
Can be used to attribute methods.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib.dll
The following managed method:
[C#]
int DoSomething (long l);
Is normally converted to:
[C#]
HRESULT DoSomething ([in] long l, [out retval] int * I);
When exported to a type library. When the PreserveSignatureAttribute is applied to the method:
[C#]
[PreserveSig] Int DoSomething (long l);
The method is exported to the type library as is:
[C#]
int DoSomething ([in] long l);
PreserveSigAttribute Members | System.Runtime.InteropServices Namespace