Missing explanation on how P/Invoke locates unmanaged libraries
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 19h 10m
- Merged PRs (30d)
- 268
Description
.NET core's docs on "default probing" mentions unmanaged libraries: https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/default-probing#unmanaged-native-library-probing
.NET Framework has docs on how it locates assemblies, but since assemblies are managed libraries, it's not entirely surprising that it doesn't mentioned unmanaged or native libraries at all: https://learn.microsoft.com/en-us/dotnet/framework/deployment/how-the-runtime-locates-assemblies
I can't find anything in the P/Invoke docs about where/how .NET Framework searches for unmanaged libraries.
Basically, say I have an "AnyCPU" .NET Framework app that uses P/Invoke to to call a native library, how do I make sure it loads the correct unmanaged library, whether the app is currently running on a x86, x64, or ARM64 machine?
---
#### Document Details
⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*
* ID: cf08b819-7446-dc6c-8040-d55ecccd317d
* Version Independent ID: 931f4809-51f0-5b61-30ec-760bcfe44cb8
* Content: [Platform Invoke (P/Invoke)](https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke)
* Content Source: [docs/standard/native-interop/pinvoke.md](https://github.com/dotnet/docs/blob/main/docs/standard/native-interop/pinvoke.md)
* Product: **dotnet-fundamentals**
* GitHub Login: @jkoritzinsky
* Microsoft Alias: **jekoritz**
Contributor guide
Assessment
This issue has not been assessed yet.