Defines a PInvoke method with the specified name, the name of the DLL in which the method is defined, the attributes of the method, the calling convention of the method, the return type of the method, the types of the parameters of the method, and the PInvoke flags.
- name
The name of the PInvoke method. name cannot contain embedded nulls.
- dllName
The name of the DLL in which the PInvoke method is defined.
- attributes
The attributes of the method.
- callingConvention
The method's calling convention.
- returnType
The method's return type.
- parameterTypes
The types of the method's parameters.
- nativeCallConv
The native calling convention.
- nativeCharSet
The method's native character set.
![]()
The defined PInvoke method.
Some DLL import attributes (see the description of System.Runtime.InteropServices.DllImportAttribute) cannot be specified as arguments to this method. Such attributes should be set by emitting a custom attribute for the method. For example, the DLL import attribute PreserveSig is set by emitting a custom attribute.
Starting with the net_v20sp1_long, this member no longer requires System.Security.Permissions.ReflectionPermission with the System.Security.Permissions.ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the net_v35_long or later.