DllImport property Preservesig

T

Tony Johansson

Hi

The doc says the following text within "". Does this text mean that if an
error occur and this property is set to false an exception is throw from the
Windows32 API ?

"This field indicates whether unmanaged methods that have HRESULT or retval
return values are directly translated or automatically converted to
exceptions.

True: The method returns a value that contains the HRESULT.

False: The method automatically converts HRESULT or retval values to
exceptions.

When you set the PreserveSig field to False, the resulting method signature
contains a void return type instead of an integer (HRESULT) return type.

The default value for this field is True."
 
F

Family Tree Mike

Hi

The doc says the following text within "". Does this text mean that if an
error occur and this property is set to false an exception is throw from the
Windows32 API ?

"This field indicates whether unmanaged methods that have HRESULT or retval
return values are directly translated or automatically converted to
exceptions.

True: The method returns a value that contains the HRESULT.

False: The method automatically converts HRESULT or retval values to
exceptions.

When you set the PreserveSig field to False, the resulting method signature
contains a void return type instead of an integer (HRESULT) return type.

The default value for this field is True."

Technically, I believe the flag means the .Net code provided by the
DllImport to call the method will intercept the HRESULT and convert it
to a thrown exception. It is a layer between your managed caller and
the unmanaged method that generates the exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top