System.Runtime.InteropServices (mscorlib.dll)sealed class

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( );


System.Object System.Attribute PreserveSigAttribute

Valid On


    Part II: Programming with the .NET Framework
    Part IV: API Quick Reference
    Chapter 26. System