DllImportAttribute.EntryPoint Field

Definition

Indicates the name or ordinal of the DLL entry point to be called.

C#
public string EntryPoint;
C#
public string? EntryPoint;

Field Value

Examples

The following code example shows how to use the DllImportAttribute attribute to import the Win32 MessageBox function. The code example uses the EntryPoint property to specify the function to import and then changes the name to MyNewMessageBoxMethod.

C#
using System;
using System.Runtime.InteropServices;

class Example
{
    // Use DllImport to import the Win32 MessageBox function.
    // Specify the method to import using the EntryPoint field and 
    // then change the name to MyNewMessageBoxMethod.
    [DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "MessageBox")]
    public static extern int MyNewMessageBoxMethod(IntPtr hWnd, String text, String caption, uint type);
    
    static void Main()
    {
        // Call the MessageBox function using platform invoke.
        MyNewMessageBoxMethod(new IntPtr(0), "Hello World!", "Hello Dialog", 0);
    }
}

Remarks

You can specify the entry-point name by supplying a string indicating the name of the DLL containing the entry point, or you can identify the entry point by its ordinal. Ordinals are prefixed with the # sign, for example, #1. If you omit this field, the common language runtime uses the name of the.NET method marked with the DllImportAttribute.

For additional information, see Identifying Functions in DLLs. For examples showing how to use the EntryPoint field, see Specifying an Entry Point.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

See also