PreserveSigAttribute

PreserveSigAttribute

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

Hierarchy

System.Object System.Attribute PreserveSigAttribute

Valid On

Method



C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net