diff --git a/docs/core/compatibility/11.md b/docs/core/compatibility/11.md index 369f0af6dd2a0..09e8d2d8c263e 100644 --- a/docs/core/compatibility/11.md +++ b/docs/core/compatibility/11.md @@ -22,6 +22,7 @@ See [Breaking changes in ASP.NET Core 11](/aspnet/core/breaking-changes/11/overv | Title | Type of change | |-------------------------------------------------------------------|-------------------| +| [Assembly.GetCallingAssembly behavior changes when stack trace support is disabled](core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md) | Behavioral change | | [CborReader and CborWriter enforce a default maximum nesting depth](core-libraries/11/cbor-max-depth.md) | Behavioral change | | [CRC32 validation added when reading ZIP archive entries](core-libraries/11/ziparchive-entry-crc32-validation.md) | Behavioral change | | [DateOnly and TimeOnly TryParse methods throw for invalid input](core-libraries/11/dateonly-timeonly-tryparse-argumentexception.md) | Behavioral change | diff --git a/docs/core/compatibility/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md b/docs/core/compatibility/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md new file mode 100644 index 0000000000000..b22fd70efe93d --- /dev/null +++ b/docs/core/compatibility/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md @@ -0,0 +1,46 @@ +--- +title: "Breaking change: Assembly.GetCallingAssembly behavior changes when stack trace support is disabled" +description: "Learn about the breaking change in .NET 11 where Assembly.GetCallingAssembly can throw NotSupportedException when stack trace support is disabled." +ms.date: 08/03/2026 +ai-usage: ai-assisted +--- + +# Assembly.GetCallingAssembly behavior changes when stack trace support is disabled + + now supports Native AOT and uses stack trace data to resolve the caller. If stack trace support is disabled, the method now throws on both Native AOT and CoreCLR. + +## Version introduced + +.NET 11 Preview 7 + +## Previous behavior + +Previously, on Native AOT, always threw . Previously, on CoreCLR, the method returned the calling assembly even if `StackTraceSupport` was set to `false`. + +## New behavior + +Starting in .NET 11, on Native AOT, returns the calling assembly by inspecting stack trace data. Starting in .NET 11, on both Native AOT and CoreCLR, the method throws if `StackTrace.IsSupported` is `false`, for example when the `StackTraceSupport` feature switch is set to `false`. + +The exception message is: + +> Unable to retrieve stack trace information when StackTraceSupport feature switch is set to false. + +## Type of breaking change + +This change is a [behavioral change](../../categories.md#behavioral-change). + +## Reason for change + +To return a correct caller, requires stack trace data. If stack trace support is unavailable, the runtime can't determine the caller reliably. The runtime now throws instead of returning an incorrect result. For Native AOT support details, see [dotnet/runtime#129963](https://github.com/dotnet/runtime/pull/129963). + +## Recommended action + +If you publish with `StackTraceSupport` set to `false` and your app calls , expect . Use one of these options: + +- Enable stack trace support by removing the switch or setting `StackTraceSupport` to `true`. +- Remove calls to . +- Catch and handle the fallback path explicitly. + +## Affected APIs + +- diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index ac20a3709ff70..086ae7c9c261b 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -10,6 +10,8 @@ items: href: 11.md - name: Core .NET libraries items: + - name: Assembly.GetCallingAssembly behavior change when stack-trace support disabled + href: core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md - name: CborReader and CborWriter enforce a default maximum nesting depth href: core-libraries/11/cbor-max-depth.md - name: CRC32 validation added when reading ZIP archive entries diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 8f777cb024bf2..5fbc929ba00be 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -77,7 +77,7 @@ Several feature areas of the framework libraries come with trimmer directives th | `MetadataUpdaterSupport` | When set to `false`, removes metadata update–specific logic related to hot reload. | | `MetricsSupport` | When set to `false`, removes support for instrumentation. | | `StackTraceLineNumberSupport` (.NET 11+) | (`PublishAot` only.) When set to `true`, generates additional line number information in the output executable module. Stack traces (for example, and ) will include information about file names and line numbers at runtime. This information is similar to the information generated into debugging symbol files (PDB/DWO/dSYM files). However, for apps published with `PublishAot`, the runtime doesn't read the native symbol files and the debugging symbols are only used by debuggers. | -| `StackTraceSupport` (.NET 8+) | When set to `false`, removes support for generating stack traces (for example, or ) by the runtime. The amount of information that is removed from stack trace strings might depend on other deployment options. This option does not affect stack traces generated by debuggers. | +| `StackTraceSupport` (.NET 8+) | When set to `false`, removes support for generating stack traces (for example, or ) by the runtime. Methods that require stack trace data, such as , throw in .NET 11 and later when this option is `false`. The amount of information that is removed from stack trace strings might depend on other deployment options. This option does not affect stack traces generated by debuggers. | | `UseNativeHttpHandler` | When set to `true`, uses the default platform implementation of for Android and iOS and removes the managed implementation. | | `UseSizeOptimizedLinq` (.NET 10+) | When set to `true`, removes some of the throughput optimizations in LINQ that adversely affect the size of the application. Defaults to `true` with `PublishAot`; it might not be possible to natively compile some applications with this property set to `false`. | | `UseSystemResourceKeys` | When set to `true`, strips exception messages for `System.*` assemblies. When an exception is thrown from a `System.*` assembly, the message is a simplified resource ID instead of the full message. |