Share via


DllImportAttribute Supported Fields

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

The DllImportAttribute attribute provides specifications for calling an unmanaged function. The .NET Compact Framework provides a subset of the attribute fields for this class, as described in the following table.

DllImportAttribute field

Description

EntryPoint

Specifies the DLL entry point to be called. The default entry point name is the name of the managed method.

CharSet

Controls the name mangling and the way that String parameters should be marshaled. The .NET Compact Framework only supports CharSet.Unicode and CharSet.Auto. CharSet.Auto equates to CharSet.Unicode on Windows CE. The default marshaling on the .NET Compact Framework is CharSet.Unicode, unlike the .NET Framework that defaults to CharSet.Ansi.

Because the .NET Compact Framework does not support the DllImportAttribute.ExactSpelling field, the common language runtime automatically searches for an entry point according to the values specified by CharSet.

CallingConvention

Specifies the calling-convention values used in passing method arguments. The default is CallingConvention.Winapi, which corresponds to __cdecl on the Windows CE platform.

SetLastError

Enables the caller to use the GetLastWin32Error method to determine whether an error occurred while executing the platform invoke method. In Visual Basic 2005, the default is true; in C#, the default is false.

Note

Because the .NET Compact Framework does not support the ExactSpelling field, the common language runtime automatically searches for an entry point according to the values specified by CharSet.

See Also

Other Resources

Platform Invoke Support