Share via

DllImportSearchPath Enum


Specifies the paths that are used to search for DLLs that provide functions for platform invokes.

This enumeration supports a bitwise combination of its member values.

public enum class DllImportSearchPath
public enum DllImportSearchPath
type DllImportSearchPath = 
Public Enum DllImportSearchPath


ApplicationDirectory 512

Include the application directory in the DLL search path.

AssemblyDirectory 2

When searching for assembly dependencies, include the directory that contains the assembly itself, and search that directory first. When used in Native AOT and single-file deployment models, the application's installation directory is considered the "assembly directory" and is searched.

LegacyBehavior 0

Search the application directory, and then call the Win32 LoadLibraryEx function with the LOAD_WITH_ALTERED_SEARCH_PATH flag. This value is ignored if any other value is specified. Operating systems that do not support the DefaultDllImportSearchPathsAttribute attribute use this value, and ignore other values.

SafeDirectories 4096

Include the application directory, the %WinDir%\System32 directory, and user directories in the DLL search path.

System32 2048

Include the %WinDir%\System32 directory in the DLL search path.

UseDllDirectoryForDependencies 256

Search for the dependencies of a DLL in the folder where the DLL is located before searching other folders.

UserDirectories 1024

Include any path that was explicitly added to the process-wide search path by using the Win32 AddDllDirectory function.


Use the DefaultDllImportSearchPathsAttribute attribute to apply a set of paths to an entire assembly or to an individual platform invoke.

Applies to