Notiz
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Iech unzemellen oder Verzeechnesser ze änneren.
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Verzeechnesser ze änneren.
Assembly.GetCallingAssembly() now supports Native AOT and uses stack trace data to resolve the caller. If stack trace support is disabled, the method now throws NotSupportedException on both Native AOT and CoreCLR.
Version introduced
.NET 11 Preview 7
Previous behavior
Previously, on Native AOT, Assembly.GetCallingAssembly() always threw PlatformNotSupportedException. 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, Assembly.GetCallingAssembly() returns the calling assembly by inspecting stack trace data. Starting in .NET 11, on both Native AOT and CoreCLR, the method throws NotSupportedException if 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.
Reason for change
To return a correct caller, Assembly.GetCallingAssembly() requires stack trace data. If stack trace support is unavailable, the runtime can't determine the caller reliably. The runtime now throws NotSupportedException instead of returning an incorrect result. For Native AOT support details, see dotnet/runtime#129963.
Recommended action
If you publish with StackTraceSupport set to false and your app calls Assembly.GetCallingAssembly(), expect NotSupportedException. Use one of these options:
- Enable stack trace support by removing the switch or setting
StackTraceSupporttotrue. - Remove calls to Assembly.GetCallingAssembly().
- Catch NotSupportedException and handle the fallback path explicitly.