|
| 1 | +--- |
| 2 | +title: "Breaking change - Linux native library resolution no longer uses `netcoredeps`" |
| 3 | +description: "Learn about the breaking change in .NET 8 where Linux applications no longer search the `netcoredeps` subdirectory for native libraries." |
| 4 | +ms.date: 4/10/2025 |
| 5 | +ai-usage: ai-assisted |
| 6 | +ms.custom: https://github.com/dotnet/docs/issues/45777 |
| 7 | +--- |
| 8 | + |
| 9 | +# Linux native library resolution no longer uses `netcoredeps` |
| 10 | + |
| 11 | +Starting in .NET 8, Linux applications no longer search the `netcoredeps` subdirectory for native libraries. |
| 12 | + |
| 13 | +## Version introduced |
| 14 | + |
| 15 | +.NET 8 |
| 16 | + |
| 17 | +## Previous behavior |
| 18 | + |
| 19 | +In earlier versions of .NET, Linux applications searched for native libraries in a `netcoredeps` subdirectory located next to the application executable. This behavior applied to all native library loads, including user-defined platform invokes (p/invokes). |
| 20 | + |
| 21 | +## New behavior |
| 22 | + |
| 23 | +In .NET 8 and later, Linux applications no longer search the `netcoredeps` subdirectory for native libraries. Native library resolution now follows standard mechanisms without relying on this subdirectory. |
| 24 | + |
| 25 | +## Type of breaking change |
| 26 | + |
| 27 | +This is a [behavioral change](../../categories.md#behavioral-change). |
| 28 | + |
| 29 | +## Reason for change |
| 30 | + |
| 31 | +The `netcoredeps` behavior was originally introduced to handle complex dependencies on third-party libraries in earlier .NET versions. .NET 8+ no longer requires this behavior due to improved dependency handling. Additionally, the mechanism isn't aligned with recommended practices for ELF platforms. |
| 32 | + |
| 33 | +For more information, see [GitHub issue #114393](https://github.com/dotnet/runtime/issues/114393). |
| 34 | + |
| 35 | +## Recommended action |
| 36 | + |
| 37 | +If your application relied on the `netcoredeps` subdirectory for p/invokes or custom native library resolution, use the following alternatives: |
| 38 | + |
| 39 | +- Implement a custom resolution mechanism using one of the following: |
| 40 | + - <xref:System.Runtime.Loader.AssemblyLoadContext.ResolvingUnmanagedDll?displayProperty=fullName> |
| 41 | + - [System.Runtime.Loader.AssemblyLoadContext.LoadUnmanagedDll](/dotnet/api/system.runtime.loader.assemblyloadcontext.loadunmanageddll) |
| 42 | + - <xref:System.Runtime.InteropServices.NativeLibrary.SetDllImportResolver(System.Reflection.Assembly,System.Runtime.InteropServices.DllImportResolver)?displayProperty=fullName> |
| 43 | + - <xref:System.Runtime.InteropServices.NativeLibrary.Load*?displayProperty=fullName> |
| 44 | +- If an `RPATH` is required in your deployment, modify the ELF file explicitly using the `patchelf` utility. |
| 45 | + |
| 46 | +## Affected APIs |
| 47 | + |
| 48 | +- `DllImport` |
| 49 | +- <xref:System.Runtime.InteropServices.NativeLibrary.Load*?displayProperty=fullName> |
0 commit comments