-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Document .NET 11 Assembly.GetCallingAssembly behavior with StackTraceSupport=false
#55213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
4
commits into
main
Choose a base branch
from
copilot/fix-assembly-getcallingassembly-behavior
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+50
−1
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ity/core-libraries/11/assembly-getcallingassembly-stacktracesupport-disabled.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
|
|
||
| <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType> now supports Native AOT and uses stack trace data to resolve the caller. If stack trace support is disabled, the method now throws <xref:System.NotSupportedException> on both Native AOT and CoreCLR. | ||
|
|
||
| ## Version introduced | ||
|
|
||
| .NET 11 Preview 7 | ||
|
|
||
| ## Previous behavior | ||
|
|
||
| Previously, on Native AOT, <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType> always threw <xref:System.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, <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType> returns the calling assembly by inspecting stack trace data. Starting in .NET 11, on both Native AOT and CoreCLR, the method throws <xref:System.NotSupportedException> if <xref:System.Diagnostics.StackTrace.IsSupported?displayProperty=nameWithType> 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, <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType> requires stack trace data. If stack trace support is unavailable, the runtime can't determine the caller reliably. The runtime now throws <xref:System.NotSupportedException> 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 <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType>, expect <xref:System.NotSupportedException>. Use one of these options: | ||
|
|
||
| - Enable stack trace support by removing the switch or setting `StackTraceSupport` to `true`. | ||
| - Remove calls to <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=nameWithType>. | ||
| - Catch <xref:System.NotSupportedException> and handle the fallback path explicitly. | ||
|
|
||
| ## Affected APIs | ||
|
|
||
| - <xref:System.Reflection.Assembly.GetCallingAssembly?displayProperty=fullName> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.