RuntimeInfrastructure mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe. System.Attribute System.AttributeUsage(System.AttributeTargets.Method, Inherited=false) System.Runtime.InteropServices.ComVisible(true)

Indicates that the target method of this attribute is an export from an unmanaged shared library.

This attribute provides the information needed to call a method exported from an unmanaged shared library. This attribute provides the name of the shared library file, the name of the method within that library, the calling convention, and character set of the unmanaged function.

A shared library refers to Dynamically Linked Libraries on Windows systems, and Shared Libraries on Unix systems.

Compilers are required to not preserve this type in metadata as a custom attribute. Instead, compilers are required to emit it directly in the file format, as described in Partition II of the CLI Specification. Metadata consumers, such as the Reflection API, are required to retrieve this data from the file format and return it as if it were a custom attribute.

The following example demonstrates the use of the .

The non-standard API used in this example indicates the current local system time.

`using System; using System.Runtime.InteropServices; [ StructLayout( LayoutKind.Sequential )] public class SystemTime { public ushort year; public ushort month; public ushort dayOfWeek; public ushort day; public ushort hour; public ushort minute; public ushort second; public ushort milliseconds; } public class LibWrap { [ DllImportAttribute( "Kernel32", CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall, EntryPoint="GetLocalTime" )] public static extern void GetLocalTime( SystemTime st ); } public class DllImportAttributeTest { public static void Main() { SystemTime st = new SystemTime(); LibWrap.GetLocalTime( st ); Console.Write( "The Date and Time is: " ); Console.Write( "{0:00}/{1:00}/{2} at ", st.month, st.day, st.year ); Console.WriteLine( "{0:00}:{1:00}:{2:00}", st.hour, st.minute, st.second ); } }`

When run at the given time on the given date, the output produced was

The Date and Time is: 05/16/2001 at 11:39:17

- Constructor
  A that specifies the name of the shared library containing the unmanaged method to import.

  Constructs and initializes a new instance of the class.

  If the shared library specified in is not found, an error occurs at runtime.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Field
  System.Boolean To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Field
  System.Runtime.InteropServices.CallingConvention

  A value that specifies the calling convention used when passing arguments to the unmanaged implementation of a method in a shared library.

  The default value is .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Field
  System.Runtime.InteropServices.CharSet

  A value that controls function name modification and indicates how the arguments to the method will be marshaled.

  This field is set to one of the values to indicate the required modifications to the name of the imported function and to the arguments of the function. The default value for is .

  If is set to , all string arguments are converted to Unicode characters before being passed to the unmanaged implementation. If the field is set to the string characters are converted to ANSI characters. If is set to , the and function name conversion is platform dependent.

  The field might also be used to determine which version of a function is imported from the specified shared library by modifying the provided name of the function. The name modification is platform specific, and includes additional characters to indicate the character set.

  The default value of this field is .

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Field
  System.String

  A that specifies the name of the shared library entry point.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Field
  System.Boolean

  A value indicating whether the name of the entry point in the unmanaged library is modified to correspond to the value specified in the field.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
- Field
  System.Boolean To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Field
  System.Boolean To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Field
  System.Boolean To be added. To be added. 1.0.5000.0 2.0.0.0 4.0.0.0
- Property
  System.String

  Gets the name of the shared library file with the entry point.

  A containing the name of the shared library file from which a function implementation is imported.

  This property is read-only.

  0
  1.0.5000.0
  2.0.0.0
  4.0.0.0
0