Skip to content

Commit c29a91a

Browse files
Cam SoperAaronRobinsonMSFTam11jkotas
authored
[Breaking change]: .NET Linux applications do not look in netcoredeps sub-directory for native libraries (#45778)
* [Breaking change]: .NET Linux applications do not look in `netcoredeps` sub-directory for native libraries Fixes #45777 * lint fix * Review feedback from @am11 * Review feedback from @jkotas * period * Apply suggestions from code review Co-authored-by: Aaron Robinson <[email protected]> Co-authored-by: Adeel Mujahid <[email protected]> Co-authored-by: Jan Kotas <[email protected]> * type of change * another fix * Apply suggestions from code review Co-authored-by: Jan Kotas <[email protected]> * indent * fixed xrefs --------- Co-authored-by: Aaron Robinson <[email protected]> Co-authored-by: Adeel Mujahid <[email protected]> Co-authored-by: Jan Kotas <[email protected]>
1 parent c7a052c commit c29a91a

File tree

3 files changed

+62
-8
lines changed

3 files changed

+62
-8
lines changed

docs/core/compatibility/8.0.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Breaking changes in .NET 8
33
titleSuffix: ""
44
description: Navigate to the breaking changes in .NET 8.
5-
ms.date: 12/05/2023
5+
ms.date: 04/10/2025
66
no-loc: [Blazor, Razor, Kestrel]
77
---
88
# Breaking changes in .NET 8
@@ -102,13 +102,14 @@ If you're migrating an app to .NET 8, the breaking changes listed here might aff
102102

103103
## Interop
104104

105-
| Title | Type of change |
106-
| ------------------------------------------------------------------------------------------------- | ------------------- |
107-
| [CreateObjectFlags.Unwrap only unwraps on target instance](interop/8.0/comwrappers-unwrap.md) | Behavioral change |
108-
| [Custom marshallers require additional members](interop/8.0/marshal-modes.md) | Source incompatible |
109-
| [IDispatchImplAttribute API is removed](interop/8.0/idispatchimplattribute-removed.md) | Binary incompatible |
110-
| [JSFunctionBinding implicit public default constructor removed](interop/8.0/jsfunctionbinding-constructor.md) | Binary incompatible |
111-
| [SafeHandle types must have public constructor](interop/8.0/safehandle-constructor.md) | Source incompatible |
105+
| Title | Type of change |
106+
|---------------------------------------------------------------------------------------------------------------|---------------------|
107+
| [CreateObjectFlags.Unwrap only unwraps on target instance](interop/8.0/comwrappers-unwrap.md) | Behavioral change |
108+
| [Custom marshallers require additional members](interop/8.0/marshal-modes.md) | Source incompatible |
109+
| [IDispatchImplAttribute API is removed](interop/8.0/idispatchimplattribute-removed.md) | Binary incompatible |
110+
| [JSFunctionBinding implicit public default constructor removed](interop/8.0/jsfunctionbinding-constructor.md) | Binary incompatible |
111+
| [SafeHandle types must have public constructor](interop/8.0/safehandle-constructor.md) | Source incompatible |
112+
| [Linux native library resolution no longer uses `netcoredeps`](interop/8.0/linux-netcoredeps.md) | Behavioral change |
112113

113114
## Networking
114115

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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>

docs/core/compatibility/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ items:
362362
href: interop/8.0/jsfunctionbinding-constructor.md
363363
- name: SafeHandle types must have public constructor
364364
href: interop/8.0/safehandle-constructor.md
365+
- name: Linux native library resolution no longer uses `netcoredeps`
366+
href: interop/8.0/linux-netcoredeps.md
365367
- name: Networking
366368
items:
367369
- name: SendFile throws NotSupportedException for connectionless sockets
@@ -1818,6 +1820,8 @@ items:
18181820
href: interop/8.0/jsfunctionbinding-constructor.md
18191821
- name: SafeHandle types must have public constructor
18201822
href: interop/8.0/safehandle-constructor.md
1823+
- name: Linux native library resolution no longer uses `netcoredeps`
1824+
href: interop/8.0/linux-netcoredeps.md
18211825
- name: .NET 7
18221826
items:
18231827
- name: RuntimeInformation.OSArchitecture under emulation

0 commit comments

Comments
 (0)