Skip to content

Make specifying just DllImportSearchPath.AssemblyDirectory only search in assembly directory #107040

Closed
@elinor-fung

Description

@elinor-fung

The DllImportSearchPath flags allow specification of where to search when looking up libraries for a p/invoke or an explicit native library load - for example, in DefaultDllImportSearchPathsAttribute or a NativeLibrary API.

The AssemblyDirectory value indicates that the directory containing the assembly of the p/invoke itself should be searched first. If DllImportSearchPath.AssemblyDirectory is the only flag specified as the search path, the runtime looks in the assembly directory first, It then falls back to the OS search behaviour. This is how the flag was designed and has behaved for its existence, but has caused confusion in the past. The current behaviour is inconsistent with how flags are usually used and also leaves the developer without a simple way to specify that only the assembly is desired.

We should consider taking a breaking change to make specifying just DllImportSearchPath.AssemblyDirectory look in the assembly directory and only the assembly directory.

cc @GrabYourPitchforks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions